{"id":20531147,"url":"https://github.com/jirihnidek/daemon","last_synced_at":"2025-05-15T23:08:04.836Z","repository":{"id":27921218,"uuid":"31413382","full_name":"jirihnidek/daemon","owner":"jirihnidek","description":"Simple example of daemon for Linux","archived":false,"fork":false,"pushed_at":"2024-10-22T10:14:38.000Z","size":34,"stargazers_count":370,"open_issues_count":2,"forks_count":112,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-08T10:34:14.459Z","etag":null,"topics":["c","example","linux","systemd","sysvinit","unix-daemon"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jirihnidek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-27T09:58:28.000Z","updated_at":"2025-03-14T20:12:41.000Z","dependencies_parsed_at":"2024-10-22T19:28:46.507Z","dependency_job_id":null,"html_url":"https://github.com/jirihnidek/daemon","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirihnidek%2Fdaemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirihnidek%2Fdaemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirihnidek%2Fdaemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirihnidek%2Fdaemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirihnidek","download_url":"https://codeload.github.com/jirihnidek/daemon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436949,"owners_count":22070947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","example","linux","systemd","sysvinit","unix-daemon"],"created_at":"2024-11-15T23:42:54.542Z","updated_at":"2025-05-15T23:07:59.787Z","avatar_url":"https://github.com/jirihnidek.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example of Linux Daemon\n\nThis repository contains simple example of daemon for Linux OS.\nThis repository also contains examples of starting scripts.\n\nWhen you want to create super simple daemon, then it is very easy.\nYou can write something like this in C and call it `daemon.c`:\n\n```c\n/* Compile this with gcc -o daemon daemon.c */\n\n#include \u003cunistd.h\u003e\n\nint main(void)\n{\n    while(1) {\n        /* TODO: do something usefull here ;-) */\n        sleep(1);\n    }\n}\n```\n\nand write some super simple systemd service file called `simple-daemon.service`:\n\n    [Unit]\n    Description=Super simple daemon\n\n    [Service]\n    Type=simple\n    ExecStart=/usr/bin/daemon\n\n    [Install]\n    WantedBy=multi-user.target\n\nand then you can run it as UNIX daemon, but such daemon do not have some\nnice features like reloadin configure files, loging, etc. This repository\nand sources can help you to understand how UNIX daemons works. \n\n## Requirements\n\nTo build example of the daemon you have to have following tools\n\n* CMake\n* GCC/CLang\n\n## Build\n\nTo build example of daemon you have to type following commands:\n\n    git clone https://github.com/jirihnidek/daemon.git\n    cd daemon\n    mkdir build\n    cd build\n    cmake -DCMAKE_INSTALL_PREFIX=/usr ../\n    make\n    sudo make install\n\n## Usage\n\nYou can test running daemon from command line:\n\n    ./bin/daemon\n\nBut running the app in this way is not running running daemon. Let\nhave a look at command line parameters and arguments\n\n    Usage: ./bin/daemon [OPTIONS]\n\n     Options:\n      -h --help                 Print this help\n      -c --conf_file filename   Read configuration from the file\n      -t --test_conf filename   Test configuration file\n      -l --log_file  filename   Write logs to the file\n      -d --daemon               Daemonize this application\n      -p --pid_file  filename   PID file used by daemonized app\n\nWhen you will run `./bin/daemon` with parameter `--daemon` or `-d`, then\nit will become real UNIX daemon. But this is not the way, how UNIX daemons\nare started nowdays. Some init scripts or service files are used for\nthis purpose.\n\nWhen you use Linux distribution using systemd, then you can try start daemon using\n\n    systemctl start simple-daemon\n    systemctl status simple-daemon\n    systemctl reload simple-daemon\n    systemctl stop simple-daemon\n\n\u003e Note: The unit files `simple-daemon.service` and `forking-daemon.service` \nare copied to the directory `/usr/lib/systemd/system` during installation using\n`make install` command.\n\nWhen you use RedHat 4/5/6 or CentOS, then you can try to use init script:\n\n    cp daemon.init /etc/rc.d/init.d/daemond\n\nThen it should be possible to control daemon using:\n\n    service daemon start\n    service daemon status\n    service daemon reload\n    service daemon stop\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirihnidek%2Fdaemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirihnidek%2Fdaemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirihnidek%2Fdaemon/lists"}