開機自啟動,node.js指令碼

來源:互聯網
上載者:User

標籤:

#!/bin/bash### BEGIN INIT INFO# Provides:  xiyoulib# Required-Start:$all# Required-Stop: $all# Default-Start: 2 3 4 5# Default-Stop:  0 1 6# Short-Description: Start daemon at boot time# Description:   Enable service provided by daemon.### END INIT INFO# chkconfig: 345 88 08# description: Forever for Node.jsDEAMON=/home/wwwroot/default/im/chat.js   #這裡需要填寫你自己的Node項目的啟動指令檔LOG=/home/wwwroot/default/im/log/log  #可選,記錄檔目錄PID=/home/wwwroot/default/im/log/pid  #必填內容,用於記錄forever的進程號export PATH=$PATH:/usr/local/bin  #在這裡指定一下Node的可執行程式安裝目錄,我的是/usr/local/binexport NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules  #這裡是Node類庫的路徑#往下的內容就不用修改了node=nodeforever=forevercase "$1" instart)$forever start -l $LOG --pidFile $PID -a $DEAMON;;stop)$forever stop --pidFile $PID $DEAMON;;stopall)$forever stopall --pidFile $PID;;restartall)$forever restartall --pidFile $PID;;reload|restart)$forever restart -l $LOG --pidFile $PID -a $DEAMON;;list)$forever list;;*)echo "Usage: /etc.init.d/node {start|stop|restart|reload|stopall|restartall|list}"exit 1;;esac

  

chmod 755 /etc/init.d/nodechkconfig /etc/init.d/node on


參考:https://cnodejs.org/topic/5059ce39fd37ea6b2f07e1a3
http://news.rednode.cn/item/53f9988079dbd26f72f69686

開機自啟動,node.js指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.