我正在EC2實例上工作,並將我的節點應用程序項目放在/ var/www /中。我正在使用upstart腳本來啓動節點應用程序。新貴腳本放置在/ etc/init /中。在應用我解析一個文件,如下訪問配置瓦爾:節點js Upstart腳本文件讀取
var _conf = JSON.parse(fs.readFileSync('./config/config.json'));
當我用命令節點上運行的應用程序在前臺app.js它工作正常。它能夠將文件解析爲JSON。但是當我運行新貴的腳本時會引發下面的錯誤。
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open './config/config.json'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Object.<anonymous> (/var/www/machaao-api/node_modules/machaao-kafka/index.js:3:27)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
[2015-12-09T07:52:05.257Z] (sys) Starting
下面是我的新貴腳本:
#!upstart
description "API Server"
author "Author"
start on startup
stop on shutdown
respawn
respawn limit 5 20
script
echo "script started..." >> /var/log/project.log
echo $$ > /var/run/project-api.pid
exec node /var/www/project-api/app.js >> /var/log/project-api.log 2>&1
end script
pre-start script
echo "Pre-start script started..."
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/project-api.log
end script
pre-stop script
echo "Pre-stop script started..."
rm /var/run/project-api.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/project-api.log
end script
有人能解釋什麼是問題?當我知道它在那裏時,它說沒有這樣的文件或目錄。我是一個新手Linux用戶。這是因爲一些權限問題嗎?
你應該發佈新貴腳本。 –
我已經在編輯 –