我有一个node.js应用程序,我正试图在生产模式下部署它,使用systemd在服务器崩溃/重启时重新启动它。当我使用'node app.js‘启动应用程序时,它工作得很好(即我所有的公共文件都被找到了)。但是,当我终止进程并重新启动systemd时,Express不能再定位我的css/js文件。我使用connect-assets来连接我的css/js文件。
我认为问题出在我的节点路径上,但我不能完全确定。这是当systemd重启应用程序时,我在浏览器中看到的错误:
500 Error ...
> 11| != css('styles')
12| != js('application')
No file found for route css/styles.css当我检查使用'node app.js‘命令手动启动的进程时,我看到:
ghost 30222 6.8 17.8 140348 90848 pts/0 Sl+ 18:01 0:08 node app.js当systemd重新启动应用程序时,我看到以下内容:
ghost 30332 5.5 9.1 94036 46516 ? Ssl 18:05 0:01 /usr/local/bin/node /home/ghost/myapp/app.js这是我的服务文件:
[Service]
ExecStart=/usr/local/bin/node /home/ghost/myapp/app.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=node-sample
User=ghost
Group=ghost
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target发布于 2015-06-09 08:35:08
您需要将WorkingDirectory=设置为Node应用程序的顶级目录,无论该目录在哪里。
例如:
WorkingDirectory=/home/ghost/myapp或者对于全球安装的应用程序,
WorkingDirectory=/usr/lib/node_modules/myapphttps://stackoverflow.com/questions/27160835
复制相似问题