Sample Header Ad - 728x90

start-stop-daemon no pid file was written

2 votes
1 answer
2404 views
Have already --make-pidfile in start-stop-daemon, but still couldn't see pid file being created. Anybody can help why? #!/bin/bash ### BEGIN INIT INFO # FIXME: set Provides and Short-Description # Provides: echobridge # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: initscript for echobridge ### END INIT INFO # FIXME: your name here # Author: Leonid Shevtsov # Do NOT "set -e" PATH=/sbin:/usr/sbin:/bin:/usr/bin # FIXME: configure your app here DESC="home automation phillips hue emulator" NAME="echobridge" CWD=/home/pi/EchoBridge DATA=/home/pi/EchoBridge/data #IP=128.168.1.40 #PORT=80 USER=pi GROUP=pi JAVA="/usr/bin/java" JVM_ARGS="-Dconfig.file=$DATA/habridge.config" JAR_PATH=/home/pi/EchoBridge/ha-bridge-3.2.1.jar #JAR_PATH=/home/pi/EchoBridge/ha-bridge-3.1.0.jar JAVA_ARGS="$JVM_ARGS -jar $JAR_PATH" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present # and status_of_proc is working. . /lib/lsb/init-functions # Test that Java is installed if [ ! -x "$JAVA" ]; then echo "Java executable not found at $JAVA" exit 2 fi # Test that the application jar is present if [ ! -r "$JAR_PATH" ]; then echo "Application JAR not found at $JAR_PATH" exit 2 fi # # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start \ --quiet \ # --name $NAME \ --make-pidfile \ --pidfile $PIDFILE \ --exec $JAVA \ --test > /dev/null \ || return 1 # FIXME: export environment variables here # export PORT=8070 start-stop-daemon --start \ --quiet \ # --name $NAME \ --make-pidfile \ --pidfile $PIDFILE \ # --chuid $USER:$GROUP \ --chdir $CWD \ --background \ --exec $JAVA \ -- $JAVA_ARGS \ || return 2 } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop \ --quiet \ # --name $NAME \ --pidfile $PIDFILE \ --exec $JAVA \ --retry=TERM/30/KILL/5 RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 rm -f $PIDFILE return "$RETVAL" } # # Function that checks if the daemon is running # do_status() { start-stop-daemon \ --start \ --test \ --oknodo \ --pidfile $PIDFILE \ --exec $JAVA } case "$1" in start) [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && echo 0 ;; 2) [ "$VERBOSE" != no ] && echo 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && echo 0 ;; 2) [ "$VERBOSE" != no ] && echo 1 ;; esac ;; status) do_status ;; restart|force-reload) echo "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) echo 0 ;; 1) echo 1 ;; # Old process is still running *) echo 1 ;; # Failed to start esac ;; *) # Failed to stop echo 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac***
Asked by dondon (21 rep)
Nov 11, 2016, 09:20 PM
Last activity: Dec 8, 2022, 09:03 AM