ubuntu - 在 Ubuntu 上创建的红隼服务因错误而停止 (code=exited, status=200/CHDIR)
问题描述
我在 /etc/systemd/system 中创建了一个服务,如下所示:
$ cd /etc/systemd/system
$ sudo nano test.service
添加以下内容
[Unit]
Description=test app
[Service]
WorkingDirectory=/var/www/test-app
ExecStart=/usr/bin/dotnet /var/www/test-app/Test.App.dll
Restart=always
RestartSec=10
SyslogIdentifier=test
User=ubuntu
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
保存服务后运行以下命令
$ sudo systemctl enable test.service
$ sudo systemctl start test.service
$ sudo systemctl status test.service
但显示此错误
test.service - test app
Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Sat 2020-02-15 10:41:19 UTC; 8s ago
Process: 24631 ExecStart=/usr/bin/dotnet /var/www/test-app/Test.App.dll (code=exited, status=200/CHDIR)
Main PID: 24631 (code=exited, status=200/CHDIR)
用户 (ubuntu) 存在并且拥有应用程序文件的适当所有权
解决方案
我有同样的问题。我尝试了使用不同目录的权限、路径长度。但问题是工作目录路径中的一个小错误。已修复,一切正常。
推荐阅读
- oracle - Oracle中一个通知事件消耗多少内存?
- python - 请求帮助使子类访问python中的主类
- batch-file - 如何在目录中循环抛出文件名,然后提取它们的名称以获取 substirng 值
- c++ - 实现双向链表
- python - 为什么即使存在需求,从带有鸡蛋片段的 git 安装 pipenv 模块也会失败?
- vb6 - 拒绝访问。未授权使用此应用程序 - 尝试实例化 com+ 对象时出现间歇性错误
- python - 基于值的列计算
- python - 根据数据框中另一列的值添加一列
- python - 通过相同的 API 信息循环多个 URL
- python - 如何从多个 Excel 工作簿中提取同一张工作表