2013-09-23 22 views
0

我有一個應用程序的內容的項目文件夾,並手動啓動它,我跑nohup npm start &然後否認了PROC。正確的方法,使一個節點應用程式服務

我想想出一個辦法,使這個service mynodeapp {start|stop|restart|etc}命令。

我也知道,Ubuntu(和Debian一般)不推薦使用SysV init腳本,而是建議在/etc/init/*.conf中使用upstart配置。

我將如何去寫與start-stop-daemon一個暴發戶的配置?

謝謝。

+0

該文件可能會幫助:http://upstart.ubuntu.com/cookbook/ – TeTeT

回答

2

我也有工作最適合我的解決辦法回答這個自己。

了一下週圍挖之後,我就決定對閱讀新貴文檔的負擔,並與/etc/init/myapp.conf以下上來:

# Node.js app config 

description  "Node.js app upstart config" 
author   "George K." 

# Starting conditions 
start on (local-filesystems and net-device-up IFACE=eth0) 

# Stopping conditions 
stop on shutdown 

# If parent or any child exits, respawn 
respawn 

# The deed 
script 
    export HOME="/root" 
    export WORKER_COUNT=4 

    exec /usr/local/bin/node /path/to/app >> /var/log/app.log 2>&1 
end script 
0

路徑:/etc/init/myapp.conf用這個命令

make文件的可執行
chmod +x myapp.conf 

myapp.conf源:

description "App Server" 
author "Author" 

start on (filesystem and net-device-up IFACE=lo) 
stop on runlevel [!2345] 

respawn 

# if your app use port 
env PORT=8080 

chdir /home/domain/public_html/chat/ 
exec node index.js 
相關問題