Introduction to start-stop-daemon
Start-stop-daemon is a daemon in Debian systems management software, users start and stop can be specified using the software.
Start-stop-daemon installation
Dpkg_1.16.18.tar.XZ download link: http://FTP.de.debian.org/debian/pool/main/d/dpkg download slower, recommended download to upload complete server, compileand install as follows:
1 2 3 4 5 6 7 |
wget http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_1.16.18.tar.xz tar -xf dpkg_1.16.18.tar.xz && cd dpkg_1.16.18 ./configure # configure: error: no curses library found yum install ncurses-devel -y ./configure && make find / -name start-stop-daemon # 查看start-stop-daemon位置 |
start-stop-daemon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
cp /usr/local/src/dpkg-1.16.18/utils/start-stop-daemon /usr/local/sbin/ ####################################################################### #!/bin/sh DESC="Jenkins CI Server" NAME=jenkins PIDFILE=/var/run/$NAME.pid RUN_AS=jenkins COMMAND="/usr/bin/java -- -jar /home/jenkins/jenkins.war" d_start() { start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND } d_stop() { start-stop-daemon --stop --quiet --pidfile $PIDFILE if [ -e $PIDFILE ] then rm $PIDFILE fi } case $1 in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; restart) echo -n "Restarting $DESC: $NAME" d_stop sleep 1 d_start echo "." ;; *) echo "usage: $NAME {start|stop|restart}" exit 1 ;; esac exit 0 |