I do not see how is used the daemon supervisor there,
BUT you edited the original post, so all I've written bellow become obsolete - still I leave it here for reference for other people.
Also, in the other thread, I have given you the example init script from its source code, to have a reference for writing your own init script.
Long story short, the "daemon" supervisor is a daemon which knows to do all nice things the daemons do (going in background, logging, etc) , but designed to execute another program.
For example, the
/usr/bin/pipewire is a regular program which does has no daemon abilities, as is designed to be executed by systemd as "user service", after the user logins, until the user logouts.
However, on Slackware -current we will want to "daemonize" it on the user side, so we use this command:
Code:
/usr/bin/daemon -frB --pidfiles=~/.run --name=pipewire /usr/bin/pipewire
The meaning of parameters:
-f run on foreground - we do not need to go background because we execute this command via a XDG autostart desktop file
-r respawn the client program if quits or crashes
-B bind to user session via elogind (not useful and/or applicable for you) and quit on logout
--pidfiles where the daemon supervisor puts the PID files of its instance and of its executed client program
--name the unique name of this instance, used in naming the PID files.
The last parameter is of course the client program, which is executed.
Again, this is the example init script given by daemon author (and found on source code tarball), as how is supposed to use it on a init script:
Code:
#!/bin/sh
# daemon - http://libslack.org/daemon/
#
# Copyright (C) 1999-2004, 2010, 2020-2021 raf <raf@raf.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# 20210304 raf <raf@raf.org>
# This is an example /etc/init.d script that shows how to use daemon(1)
# in that context. Note that this would need to be modified quite a bit
# to meet the usual conventions of any specific system but if you aren't
# concerned about that it should be usable. At least it's a starting point.
# The daemon's name (to ensure uniqueness and for stop, restart and status)
name="EXAMPLE"
# The path of the client executable
command="/usr/bin/EXAMPLE"
# Any command line arguments for the client executable
command_args=""
# The path of the daemon executable
daemon="/usr/bin/daemon"
[ -x "$daemon" ] || exit 0
[ -x "$command" ] || exit 0
# Note: The following daemon option arguments could be in /etc/daemon.conf
# instead. That would probably be better because if the command itself were
# there as well then we could just use the name here to start the daemon.
# Here's some code to do it here in case you prefer that.
# Any command line arguments for the daemon executable (when starting)
daemon_start_args="" # e.g. --inherit --env="ENV=VAR" --unsafe
# The pidfile directory (need to force this so status works for normal users)
pidfiles="/var/run"
# The user[:group] to run as (if not to be run as root)
user=""
# The path to chroot to (otherwise /)
chroot=""
# The path to chdir to (otherwise /)
chdir=""
# The umask to adopt, if any
umask=""
# The syslog facility or filename for the client's stdout (otherwise discarded)
stdout="daemon.info"
# The syslog facility or filename for the client's stderr (otherwise discarded)
stderr="daemon.err"
case "$1" in
start)
# This if statement isn't strictly necessary but it's user friendly
if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
then
echo "$name is already running."
else
echo -n "Starting $name..."
"$daemon" --respawn $daemon_start_args \
--name "$name" --pidfiles "$pidfiles" \
${user:+--user $user} ${chroot:+--chroot $chroot} \
${chdir:+--chdir $chdir} ${umask:+--umask $umask} \
${stdout:+--stdout $stdout} ${stderr:+--stderr $stderr} \
-- \
"$command" $command_args
echo done.
fi
;;
stop)
# This if statement isn't strictly necessary but it's user friendly
if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
then
echo -n "Stopping $name..."
"$daemon" --stop --name "$name" --pidfiles "$pidfiles"
echo done.
else
echo "$name is not running."
fi
;;
restart|reload)
if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
then
echo -n "Restarting $name..."
"$daemon" --restart --name "$name" --pidfiles "$pidfiles"
echo done.
else
echo "$name is not running."
exit 1
fi
;;
status)
"$daemon" --running --name "$name" --pidfiles "$pidfiles" --verbose
;;
*)
echo "usage: $0 <start|stop|restart|reload|status>" >&2
exit 1
esac
exit 0
# vi:set ts=4 sw=4: