#author("2017-05-01T15:27:39+09:00","default:admin","admin")
#author("2017-05-01T15:28:07+09:00","default:admin","admin")
-[[シェルスクリプトをdaemon化する方法:http://itkobo-z.jp/archives/2115]]
-[[Supervisorで簡単にデーモン化:http://qiita.com/yushin/items/15f4f90c5663710dbd56]]

*start-stop-daemon [#u3829d4f]
-[[start-stop-daemonいじってみた:https://freedom-man.com/blog/start-stop-daemon/]]
-[[Man page of start-stop-daemon:http://jnug.net/po4a/monyo/start-stop-daemon.ja.8.html]]
-[[init.d スクリプトを書こう:http://surf.ml.seikei.ac.jp/~nakano/linux/init.d.html]]

**入手 [#a3e45e9e]
-[[Using start-stop-daemon on CentOS:http://blog.starcklin.com/2014/01/using-start-stop-daemon-centos/]]
-[[dpkg_1.17.6.tar.xz:https://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjv2NPO-83TAhXBfbwKHUM_Cz8QFggnMAA&url=https%3A%2F%2Flaunchpadlibrarian.net%2F162580657%2Fdpkg_1.17.6.tar.xz&usg=AFQjCNGwmhEeS4v3bdSZ6119NtdntNzCfA&sig2=Is98d6Ma2fbUiKjch6rYQQ]]

 $ tar -xf dpkg_1.17.6.tar.xz
 $ cd dpkg-1.17.6
 $ sudo yum install ncurses-devel ncurses
 $ ./configure
 $ make
 $ cd utils
 $ sudo cp start-stop-daemon /usr/local/bin

**使用 [#df369c17]

 #!/bin/bash
 DAEMON=/usr/bin/python
 PIDFILE=/home/xxx/hoge.pid
 DAEMON_ARGS=/home/xxx/hoge.py
 
 case "$1" in
   "start")
     start-stop-daemon --start --quiet --background --exec $DAEMON --make-pidfile --pidfile $PIDFILE -- $DAEMON_ARGS
     start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
    result=$?
    if [ $result != "0" ]
    then
      pid=`cat $PIDFILE`
      echo "daemon is already running. (pid=${pid})"
      exit 1
    fi
    ;;
  "stop")
    start-stop-daemon --stop --quiet --pidfile $PIDFILE
    result=$?
    if [ $result != "0" ]
    then
      echo "daemon is not running. (check $PIDFILE)."
      exit 1
    fi
    rm -f $PIDFILE
    ;;
 esac


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS