![systemd 在步骤用户处失败,没有生成这样的进程](https://linux22.com/image/1608025/systemd%20%E5%9C%A8%E6%AD%A5%E9%AA%A4%E7%94%A8%E6%88%B7%E5%A4%84%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%B2%A1%E6%9C%89%E7%94%9F%E6%88%90%E8%BF%99%E6%A0%B7%E7%9A%84%E8%BF%9B%E7%A8%8B.png)
我正在尝试使用 systemctl 运行我的自定义服务,但它总是出现错误:
Oct 29 14:09:30 ip-10-0-0-215.ap-southeast-1.compute.internal systemd[12402]: Failed at step USER spawning /home/ec2-user/zuul/target/zuul.jar: No such process
Oct 29 14:09:30 ip-10-0-0-215.ap-southeast-1.compute.internal systemd[1]: zuul.service: main process exited, code=exited, status=217/USER
Oct 29 14:09:30 ip-10-0-0-215.ap-southeast-1.compute.internal systemd[1]: Unit zuul.service entered failed state.
Oct 29 14:09:30 ip-10-0-0-215.ap-southeast-1.compute.internal systemd[1]: zuul.service failed.
zuul.service中的配置:
[Unit]
Description=leave service
[Service]
User=ec2-user
# The configuration file application.properties should be here:
#change this to your workspace
WorkingDirectory=/home/ec2-user
#path to executable.
#executable is a bash script which calls jar file
ExecStart=/home/ec2-user/project-error-404/microservice/leaveService/target/leaveService.jar
SuccessExitStatus=143
TimeoutStopSec=10
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
我运行该服务的方式是:
sudo systemctl daemon-reload
sudo systemctl enable zuul.service
sudo systemctl start zuul
我尝试从服务文件中删除用户,但没有帮助。我确信文件和目录的所有者是 ec2-user。使用相同的配置,它可以在我的其他实例上运行。但我花了几个小时却没有找到解决方案。
答案1
我想我找到原因了。我需要安装 java 运行时。但是错误日志根本没有帮助,我只是随机尝试了一切可能的方法来解决这个问题。
奇怪的是,我可以在普通命令上完美运行它,(但我用 sdkman 安装了 java,我认为这就是原因)
所以对我来说解决方案就是 sudo yum install java