小编F1L*_*nux的帖子

centos 7 systemd :活动:失败(结果:启动限制)

我想用我的Django项目使用uwsgi
我测试usgi --ini uwsgi.ini 效果很好

而我想写进去systemd控制它
面对错误

这是我的文件

/etc/systemd/system/mysite.service

[Unit]
Description=uWSGI for proj
After=syslog.target

[Service]
Restart=always
ExecStart=/usr/bin/uwsgi --ini  /usr/share/nginx/ENV/proj/proj/uwsgi.ini
StandardError=syslog
KillSignal=SIGQUIT
Type=forking
NotifyAccess=main

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

我第一次使用systemctl restart mysite.service
它效果很好,然后我使用systemctl stop mysite.service
然后重新启动systemctl restart mysite.service

但是停止后它无法重新启动
我收到错误:

proj.service - uWSGI for proj
   Loaded: loaded (/usr/lib/systemd/system/proj.service; disabled)
   Active: failed (Result: start-limit) since Fri 2015-11-13 13:40:35 CST; 887ms ago
  Process: 4297 ExecStart=/usr/bin/uwsgi --ini /usr/share/nginx/ENV/proj/proj/uwsgi.ini (code=exited, status=0/SUCCESS)
 Main PID: 4298 (code=exited, status=0/SUCCESS)

Nov 13 13:40:35 localhost.localdomain systemd[1]: proj.service …
Run Code Online (Sandbox Code Playgroud)

centos systemd services uwsgi

9
推荐指数
1
解决办法
4万
查看次数

使用 OnFailure= 和 Restart= 混淆 systemd 行为

我在嵌入式系统中使用 systemd 231,并且我正在尝试创建一个服务来监视系统中的硬件组件。这是我正在尝试做的事情的粗略描述:

  1. 当服务 ,foo.service启动时,它会启动一个应用程序foo_app
  2. foo_app监控硬件组件,持续运行。
  3. 如果foo_app检测到硬件故障,它会以返回码 1 退出。这应该会触发系统重新启动。
  4. 如果foo_app崩溃,systemd 应该重新启动foo_app
  5. 如果foo_app 反复崩溃,systemd 应该重新启动系统。

这是我将其实现为服务的尝试:

[Unit]
Description=Foo Hardware Monitor

# If the application fails 3 times in 30 seconds, something has gone wrong,
# and the state of the hardware can't be guaranteed. Reboot the system here.
StartLimitBurst=3
StartLimitIntervalSec=30
StartLimitAction=reboot

# StartLimitAction=reboot will reboot the box if the app fails repeatedly,
# but if the app exits …
Run Code Online (Sandbox Code Playgroud)

systemd services

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

services ×2

systemd ×2

centos ×1

uwsgi ×1