我有一个聊天机器人应用程序,它应该使用 systemctl 作为服务运行。每当我尝试启动聊天机器人服务时,我都会收到错误并且服务失败。
如果我直接从终端启动聊天机器人,它就可以正常工作。但是当我将其作为服务启动时则不行。
我的问题是我不知道这是聊天机器人故障还是服务故障。
Loaded: loaded (/etc/systemd/system/chatbot.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-08-27 09:44:01 CEST; 5s ago
Process: 9634 ExecStart=/home/chatbot_eng/chatbot/bp (code=exited, status=1/FAILURE)
Main PID: 9634 (code=exited, status=1/FAILURE)
Aug 27 09:44:01 s2.test.com bp[9634]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:711:10)
Aug 27 09:44:01 s2.test.com bp[9634]: at Module.load (internal/modules/cjs/loader.js:610:32)
Aug 27 09:44:01 s2.test.com bp[9634]: at tryModuleLoad (internal/modules/cjs/loader.js:549:12)
Aug 27 09:44:01 s2.test.com bp[9634]: at Function.Module._load (internal/modules/cjs/loader.js:541:3)
Aug 27 09:44:01 s2.test.com bp[9634]: at Function.Module.runMain (pkg/prelude/bootstrap.js:1309:12)
Aug 27 09:44:01 s2.test.com bp[9634]: at startup (internal/bootstrap/node.js:274:19)
Aug 27 09:44:01 s2.test.com bp[9634]: at bootstrapNodeJSCore (internal/bootstrap/node.js:608:3)
Aug 27 09:44:01 s2.test.com systemd[1]: chatbot.service: Main process exited, code=exited, status=1/FAILURE
Aug 27 09:44:01 s2.test.com systemd[1]: chatbot.service: Unit entered failed state.
Aug 27 09:44:01 s2.test.com systemd[1]: chatbot.service: Failed with result 'exit-code'.
当我使用进程 ID 执行 journalctl 时,我得到:
Aug 27 09:44:01 s2.test.com bp[9634]: path.js:39
Aug 27 09:44:01 s2.test.com bp[9634]: throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
Aug 27 09:44:01 s2.test.com bp[9634]: ^
Aug 27 09:44:01 s2.test.com bp[9634]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
Aug 27 09:44:01 s2.test.com bp[9634]: at assertPath (path.js:39:11)
Aug 27 09:44:01 s2.test.com bp[9634]: at Object.join (path.js:1157:7)
Aug 27 09:44:01 s2.test.com bp[9634]: at getAppDataPath (/snapshot/build-linux/out/bp/core/misc/app_data.js:0:0)
Aug 27 09:44:01 s2.test.com bp[9634]: at Object.<anonymous> (/snapshot/build-linux/out/bp/index.js:0:0)
Aug 27 09:44:01 s2.test.com bp[9634]: at Module._compile (pkg/prelude/bootstrap.js:1254:22)
Aug 27 09:44:01 s2.test.com bp[9634]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:711:10)
Aug 27 09:44:01 s2.test.com bp[9634]: at Module.load (internal/modules/cjs/loader.js:610:32)
Aug 27 09:44:01 s2.test.com bp[9634]: at tryModuleLoad (internal/modules/cjs/loader.js:549:12)
Aug 27 09:44:01 s2.test.com bp[9634]: at Function.Module._load (internal/modules/cjs/loader.js:541:3)
Aug 27 09:44:01 s2.test.com bp[9634]: at Function.Module.runMain (pkg/prelude/bootstrap.js:1309:12)
Aug 27 09:44:01 s2.test.com bp[9634]: at startup (internal/bootstrap/node.js:274:19)
Aug 27 09:44:01 s2.test.com bp[9634]: at bootstrapNodeJSCore (internal/bootstrap/node.js:608:3)
这是我的服务:
[Unit]
Description=Chatbot
[Service]
ExecStart=/home/chatbot_eng/chatbot/bp
[Install]
WantedBy=multi-user.target