Skip to content

Commit

Permalink
Updated cmake to install systemd unit files during make install. Fixe…
Browse files Browse the repository at this point in the history
…d path to binary in unit files.
  • Loading branch information
Jiri Hnidek committed Nov 1, 2016
1 parent 717e62e commit 8b3b483
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ add_subdirectory (src)
# Directory with configuration files
set (DAEMON_CONF_DIR "/etc/daemon")

# Directory with systemd unit files
set (SYSTEMD_UNIT_DIR "/usr/lib/systemd/system/")

# Macro for installing configuration files
function(install_conf src dest)
if(NOT IS_ABSOLUTE "${src}")
Expand Down Expand Up @@ -61,4 +64,8 @@ function(install_conf src dest)
endfunction(install_conf)

# Install configuration file
install_conf (./daemon.conf ${DAEMON_CONF_DIR})
install_conf (./daemon.conf ${DAEMON_CONF_DIR})

# Install systemd unit files
install_conf (./simple-daemon.service ${SYSTEMD_UNIT_DIR})
install_conf (./forking-daemon.service ${SYSTEMD_UNIT_DIR})
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,17 @@ it will become real UNIX daemon. But this is not the way, how UNIX daemons
are started nowdays. Some init scripts or service files are used for
this purpose.
When you use Linux distribution using systemd, then you can try to copy
file `forking-daemon.service` or `simple-daemon.service` to directory:
/usr/lib/systemd/system
and then start daemon using
When you use Linux distribution using systemd, then you can try start daemon using
systemctl start simple-daemon
systemctl status simple-daemon
systemctl reload simple-daemon
systemctl stop simple-daemon
> Note: The unit files `simple-daemon.service` and `forking-daemon.service`
are copied to the directory `/usr/lib/systemd/system` during installation using
`make install` command.
When you use RedHat 4/5/6 or CentOS, then you can try to use init script:
cp daemon.init /etc/rc.d/init.d/daemond
Expand Down
2 changes: 1 addition & 1 deletion forking-daemon.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description=Example of forking daemon program
[Service]
Type=forking
PIDFile=/var/run/daemon.pid
ExecStart=/usr/bin/daemon \
ExecStart=/usr/local/bin/daemon \
--conf_file /etc/daemon/daemon.conf \
--log_file /var/log/daemon.log \
--pid_file /var/run/daemon.pid \
Expand Down
2 changes: 1 addition & 1 deletion simple-daemon.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=Example of simple daemon program

[Service]
Type=simple
ExecStart=/usr/bin/daemon \
ExecStart=/usr/local/bin/daemon \
--conf_file /etc/daemon/daemon.conf \
--log_file /var/log/daemon.log
User=root
Expand Down

0 comments on commit 8b3b483

Please sign in to comment.