【发布时间】:2022-01-28 11:13:01
【问题描述】:
我创建了一个 systectl 服务来运行节点应用程序,但应用程序使用 discordJs(npm 包),它仅适用于节点 v16.* 及更高版本(我猜)。
现在的问题是,这个服务正在使用节点 v10.21.0,这就是为什么我的应用程序一启动就崩溃了!
我找不到更改此服务的节点版本的方法。
系统节点版本为v16.13.1
animeland.service 配置:
[Unit]
Description=bot for animeland server
Wants=network-online.target
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/bots/chika-bot/
ExecStart=npm start
[Install]
WantedBy=multi-user.target
启动后的服务状态:
pi@rootz491:~ $ sudo systemctl start animeland.service
pi@rootz491:~ $ sudo systemctl status animeland.service
● animeland.service - bot for animeland server
Loaded: loaded (/etc/systemd/system/animeland.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-01-28 16:44:42 IST; 5s ago
Process: 2195 ExecStart=/usr/bin/npm start (code=exited, status=1/FAILURE)
Main PID: 2195 (code=exited, status=1/FAILURE)
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! errno 1
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! chika@1.0.0 start: `node index.js`
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! Exit status 1
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR!
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! Failed at the chika@1.0.0 start script.
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! This is probably not a problem with npm. There is likely additional l
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! A complete log of this run can be found in:
Jan 28 16:44:42 rootz491 npm[2195]: npm ERR! /home/pi/.npm/_logs/2022-01-28T11_14_42_719Z-debug.log
Jan 28 16:44:42 rootz491 systemd[1]: animeland.service: Main process exited, code=exited, status=1/FAILURE
Jan 28 16:44:42 rootz491 systemd[1]: animeland.service: Failed with result 'exit-code'.
结论:
如果你们知道如何更改 systemctl 服务的节点版本,请知道这将是一个很大的帮助!
谢谢
【问题讨论】:
-
你应该升级你的节点版本。
-
系统节点最新版本:pastebin.com/zexTsqEH
标签: node.js linux service automation systemd