这将是我的第一个节点部署。我有这个应用程序在我的Debian 9服务器上运行正常使用此命令:
cd /srv/myapp && NODE_ENV=production yarn start
打印出这条消息:
yarn run v1.6.0
$ babel-node index.js
为了使用systemd妖魔化app,我创建了`/lib/systemd/system/myapp.service:
[Unit]
Description=Myapp
[Service]
ExecStart=/home/john/start.sh
Type=simple
User=john
Restart=on-failure
[Install]
WantedBy=multi-user.target
并在start.sh
我有:
cd /srv/myapp && NODE_ENV=production yarn start
Hoewever,当我运行systemctl start myapp
时,节点应用程序没有按预期开始侦听端口3000(netstat -tulpn | grep :3000
没有返回结果)
# systemctl status myapp
● myapp.service - Myapp
Loaded: loaded (/lib/systemd/system/myapp.service; disabled; vendor preset: enabled
Active: failed (Result: exit-code) since Sun 2018-05-13 06:14:04 EDT; 5s ago
Process: 8852 ExecStart=/home/bob/start.sh (code=exited, status=203/EXEC)
Main PID: 8852 (code=exited, status=203/EXEC)
May 13 06:14:04 9606 systemd[1]: myapp.service: Unit entered failed state.
May 13 06:14:04 9606 systemd[1]: myapp.service: Failed with result 'exit-code'.
May 13 06:14:04 9606 systemd[1]: myapp.service: Service hold-off time over, scheduling
May 13 06:14:04 9606 systemd[1]: Stopped myapp.
May 13 06:14:04 9606 systemd[1]: myapp.service: Start request repeated too quickly.
May 13 06:14:04 9606 systemd[1]: Failed to start myapp.
May 13 06:14:04 9606 systemd[1]: myapp.service: Unit entered failed state.
May 13 06:14:04 9606 systemd[1]: myapp.service: Failed with result 'exit-code'.
我在myapp.service上有其他变体,但无法管理运行节点。
这里有什么问题?我该如何解决?
答案 0 :(得分:1)
Process: 8852 ExecStart=/home/bob/start.sh (code=exited, status=203/EXEC)
根据systemd.exec
(5),这意味着systemd
无法执行指定的文件:
203 EXIT_EXEC实际的进程执行失败(具体来说,是execve(2)系统调用)。这很可能是由丢失或不可访问的可执行文件引起的。
您应该检查/home/bob/start.sh
是否可执行并且指定了正确的shebang(即,脚本的第一行必须是#!/bin/bash
)。