Wir empfehlen Ihnen dringend, den init.d-Standard für Schreibdienste zu verwenden. Dies führt auch zu weniger Verwirrung, wenn eine andere Person, die sich mit init.d-Diensten auskennt, diese betrachtet. Bitte sehen Sie das Beispiel unten:
#!/bin/sh # # Author: Your Name <email@address.domain> # ### BEGIN INIT INFO # Provides: Name # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Should-Start: $syslog # Should-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Add a description here ### END INIT INFO # Using LSB functions: . /lib/lsb/init-functions set -e NAME="NAME" DAEMON=/opt/app/app.js PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Function that starts the daemon/service. d_start() { log_daemon_msg "Starting" "$NAME" start-stop-daemon --start --quiet --background --pidfile $PIDFILE --make-pidfile --startas $DAEMON log_end_msg $? } # Function that stops the daemon/service. d_stop() { log_daemon_msg ":: stopping" "$NAME" start-stop-daemon --stop --pidfile $PIDFILE --retry 10 log_end_msg $? } # Function that sends a SIGHUP to the daemon/service. case "$1" in start|stop) d_$ ;; restart|reload|force-reload) d_stop sleep 1 d_start ;; status) status_of_proc "$NAME" "$DAEMON" && exit 0 || exit $? ;; *) echo "Usage: $SCRIPTNAME " exit 3 ;; esac exit 0