我试图将节点应用程序设置为service
并启动服务,我需要使用绝对路径来启动节点,这意味着我必须以usr/bin/node
来启动它,但是无论如何原因是使用此绝对路径时我的应用程序无法正常工作。
root@server:/etc/systemd/system# node /var/www/gwart./mediawiki/extensions/VisualEditor/parsoid/bin/server.js
{"name":"parsoid","hostname":"server.live-servers.net","pid":25057,"level":30,"levelPath":"info/service-runner","msg":"master(25057) initializing 2 workers","time":"2018-12-15T21:47:27.192Z","v":0}
{"name":"lib/index.js","hostname":"server.live-servers.net","pid":25068,"level":30,"levelPath":"info","msg":"loading ...","time":"2018-12-15T21:47:28.749Z","v":0}
{"name":"lib/index.js","hostname":"server.live-servers.net","pid":25068,"level":30,"levelPath":"info","msg":"ready on :8000","time":"2018-12-15T21:47:28.781Z","v":0}
{"name":"lib/index.js","hostname":"server.live-servers.net","pid":25082,"level":30,"levelPath":"info","msg":"loading ...","time":"2018-12-15T21:47:30.325Z","v":0}
{"name":"lib/index.js","hostname":"server.live-servers.net","pid":25082,"level":30,"levelPath":"info","msg":"ready on :8000","time":"2018-12-15T21:47:30.351Z","v":0}
{"name":"parsoid","hostname":"server.live-servers.net","pid":25057,"level":40,"levelPath":"warn/service-runner","msg":"startup finished","time":"2018-12-15T21:47:30.353Z","v":0}
{"name":"parsoid","hostname":"server.live-servers.net","pid":25082,"level":30,"logType":"info","wiki":"wiki$0","title":"Main_Page","oldId":null,"reqId":null,"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36","msg":"started wt2html","longMsg":"started wt2html","levelPath":"info","time":"2018-12-15T21:47:39.266Z","v":0}
{"name":"parsoid","hostname":"server.live-servers.net","pid":25082,"level":30,"logType":"info","wiki":"wiki$0","title":"Main_Page","oldId":5,"reqId":null,"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36","msg":"completed wt2html in 1144.7718710899353ms","longMsg":"completed wt2html in 1144.7718710899353ms","levelPath":"info","time":"2018-12-15T21:47:40.391Z","v":0}
^Z
[23]+ Stopped
root@server:/etc/systemd/system# /usr/bin/node /var/www/gwart/mediawiki/extensions/VisualEditor/parsoid/bin/server.js
{"name":"parsoid","hostname":"server.live-servers.net","pid":25145,"level":30,"levelPath":"info/service-runner","msg":"master(25145) initializing 2 workers","time":"2018-12-15T21:47:49.939Z","v":0}
{"name":"parsoid","hostname":"server.live-servers.net","pid":25155,"level":60,"moduleName":"lib/index.js","levelPath":"fatal/service-runner/worker","msg":"Unexpected token ...","time":"2018-12-15T21:47:50.657Z","v":0}
{"name":"parsoid","hostname":"server.live-servers.net","pid":25145,"level":40,"message":"first worker died during startup, continue startup","worker_pid":25155,"exit_code":1,"startup_attempt":1,"levelPath":"warn/service-runner/master","msg":"first worker died during startup, continue startup","time":"2018-12-15T21:47:51.668Z","v":0}
答案 0 :(得分:1)
您可能在不同的路径上安装了不同版本的节点,并且您的应用程序可能需要特定版本才能正确运行。考虑将console.log(process.version);
添加到脚本的开头,用两个命令运行它,然后比较输出。如果它们是不同的版本,则可能需要将符号链接添加到/usr/bin/node
中nvm文件夹中的正确版本。