我通過我的ec2 linux實例上的屏幕運行我的app.js(節點js應用程序)。 我想配置我的monitrc文件,我需要應用程序pidfile。 這不是在: /var/run中 (並沒有一個在/ var/WWW)配置監控節點js應用進程的monitrc,找不到節點應用pidfile與屏幕ec2運行linux
會很感激,如果有人有任何想法的地方是pidfile進程文件或我怎麼能找到它..
謝謝!
我通過我的ec2 linux實例上的屏幕運行我的app.js(節點js應用程序)。 我想配置我的monitrc文件,我需要應用程序pidfile。 這不是在: /var/run中 (並沒有一個在/ var/WWW)配置監控節點js應用進程的monitrc,找不到節點應用pidfile與屏幕ec2運行linux
會很感激,如果有人有任何想法的地方是pidfile進程文件或我怎麼能找到它..
謝謝!
好像沒有建立,所以我用一個pid文件永遠監視器,以便在發生錯誤時重新啓動我的app.js腳本。 看起來像是在工作。 你需要做的是NPM安裝永遠 寫server.js:
var forever = require('forever'),
child = new(forever.Monitor)('app.js', {
'silent': false,
'pidFile': '/var/run/app.pid',
'watch': false,
'options': ['8383'], // Additional arguments to pass to the script,
'sourceDir': '.', // Directory that the source script is in
'watchDirectory': '.', // Top-level directory to watch from.
'watchIgnoreDotFiles': true, // whether to ignore dot files
'watchIgnorePatterns': [], // array of glob patterns to ignore, merged with contents of watchDirectory + '/.foreverignore' file
'logFile': 'logs/forever.log', // Path to log output from forever process (when daemonized)
'outFile': 'logs/forever.out', // Path to log output from child stdout
'errFile': 'logs/forever.err'
});
child.start();
forever.startServer(child);
,然後用運行 - 節點server.js(從我〜/目錄下的NodeJS運行) 仍是PID文件應該在/ var/run中不存在,很奇怪,但我不需要monit了。 我仍然不明白爲什麼我應該另外使用暴發戶(如所有相關的帖子建議)無論如何,當我試圖運行暴發戶它不起作用
你可以得到process.pid所以
var fs = require('fs');
fs.writeFile("/tmp/pidfile", process.pid);
當前PID號碼,你tmp中得到一個pidfile進程文件
謝謝,但我需要的過程pidfile不是pid號 – Liatz
也許我不會不明白你想要什麼,但是pidfile只是一個帶有PID號碼的文件。 –
但當進程重新啓動時,pid會改變。無論如何,這是monitrc配置需要的。我必須給它pid文件路徑。 – Liatz