服务设置自动重启

使用systemctl管理服务,如kibana

设置自动重启的参数 StartLimitIntervalSec=0 Restart=always

RestartSec=1

  1. #vim /etc/systemd/system/kibana.service
  2. [Unit]
  3. Description=Kibana
  4. [Service]
  5. Type=simple
  6. User=kibana
  7. Group=kibana
  8. # Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
  9. # Prefixing the path with '-' makes it try to load, but if the file doesn't
  10. # exist, it continues onward.
  11. EnvironmentFile=-/etc/default/kibana
  12. EnvironmentFile=-/etc/sysconfig/kibana
  13. ExecStart=/usr/share/kibana/bin/kibana "-c /etc/kibana/kibana.yml"
  14. Restart=always
  15. StartLimitIntervalSec=0
  16. RestartSec=1
  17. WorkingDirectory=/
  18. [Install]
  19. WantedBy=multi-user.target

使用supervisord设置自动重启,如ardb
  1. #cat /etc/supervisord/conf.d/ardb.conf
  2. [program:ardb]
  3. directory=/opt/db/ardb
  4. command=/opt/db/ardb/src/ardb-server /opt/db/ardb/ardb.conf
  5. numprocs=1
  6. user=root
  7. autostart=true
  8. autorestart=true
  9. redirect_stderr=true
  10. stdout_logfile=/opt/db/ardb/log/ardb-server.log
  11. stdout_logfile_maxbytes=200MB
  12. stdout_logfile_backups=20