Ubuntu下設置godoc/gotour開機自啟動
編寫godoc啟動腳本 /etc/init.d/godoc , 內容如下.
#!/bin/bash set -eBEGIN INIT INFO
Provides: godoc
Required-Start: $local_fs $remote_fs $network $time
Required-Stop: $local_fs $remote_fs $network $time
Should-Start: $syslog
Should-Stop: $syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: go online documention server
END INIT INFO
Setting environment variables for the postmaster here does not work; please
set them in /etc/postgresql/<version>/<cluster>/environment instead.
[ -f /usr/local/go/bin/godoc ] || exit 0
case "$1" in start) nohup godoc -index -http=:6060 > /dev/null 2>&1 & ;; stop) pkill -9 godoc 2> /dev/null ;; status) ps aux | head -1 ps aux | grep [6]060 ;; *) echo "Usage: $0 {start|stop|status}" exit 1 ;; esac
exit 0</pre>
設置腳本開機啟動.# 設置godoc在2,3,4,5系統啟動等級,順序77啟動. 在0,1,6系統啟動登記,順序55停止. update-rc.d godoc start 77 2 3 4 5 . stop 55 0 1 6 .
編寫gotour啟動腳本 /etc/init.d/gotour , 內容如下.
#!/bin/bash set -eBEGIN INIT INFO
Provides: gotour
Required-Start: $local_fs $remote_fs $network $time
Required-Stop: $local_fs $remote_fs $network $time
Should-Start: $syslog
Should-Stop: $syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: go online tour server
END INIT INFO
Setting environment variables for the postmaster here does not work; please
set them in /etc/postgresql/<version>/<cluster>/environment instead.
[ -f /usr/local/go/bin/gotour ] || exit 0
case "$1" in start) nohup gotour > /dev/null 2>&1 & ;; stop) pkill -9 gotour 2> /dev/null ;; status) ps aux | head -1 ps aux | grep [t]our ;; *) echo "Usage: $0 {start|stop|status}" exit 1 ;; esac
exit 0</pre>
設置腳本開機啟動.# 設置gotour在2,3,4,5系統啟動等級,順序77啟動. 在0,1,6系統啟動登記,順序55停止. update-rc.d gotour start 77 2 3 4 5 . stop 55 0 1 6 .以上設置完成后, godoc與gotour將會在系統啟動時自動啟動,系統停止時自動殺死.
如果需要移除命令系統自啟動.
執行如下命令即可
update-rc.d -f godoc remove && rm -f /etc/init.d/godoc update-rc.d -f gotour remove && rm -f /etc/init.d/gotour
本文由用戶 灬猜想灬 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!