systemd下supervisord服務開機自啟動以及注意事項

來源:互聯網
上載者:User

標籤:systemd   top   設定檔   java_home   home   git   問題   get   limit   

systemd 下supervisord服務開機自啟動centos7 開機自啟動指令碼:
#vim /lib/systemd/system/supervisord.service# supervisord service for sysstemd (CentOS 7.0+)# by ET-CS (https://github.com/ET-CS)[Unit]Description=Supervisor daemon[Service]ExecStart=/usr/bin/supervisordExecStop=/usr/bin/supervisorctl $OPTIONS shutdownExecReload=/usr/bin/supervisorctl $OPTIONS reloadKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target

這個自啟動指令碼需要修改/etc/supervisord.conf設定檔:

????#vim /etc/supervisrod.conf
????????nodaemon=false????改成true

或者:#vim /lib/systemd/system/supervisord.service

[Unit]Description=Process Monitoring and Control DaemonAfter=rc-local.service[Service]Type=forkingExecStart=/usr/bin/supervisord -c /etc/supervisord.confSysVStartPriority=99[Install]WantedBy=multi-user.target

無需修改/etc/supervisord.conf設定檔

兩個自啟動指令碼都能夠添加到systemctl自啟動服務

#systemctl enable supervisord.service
#systemctl start/restart/stop supervisor.service

systemd 下supervisor服務自啟動服務管理有變數的服務

但是當superviosr被管理的服務有環境變數,是會有問題(比如啟動elasticserch服務,有JAVA_HOME和limit.conf的依賴),原因:/etc/profile或者/etc/security/limit.conf 這些檔案中配置的環境變數僅對通過pam登入的使用者生效,
而systemd是不讀這些配置的,所以這就造成登入到終端時查看環境變數和手動啟動應用都一切正常,但是systemd無法正常啟動應用

擷取可以通過添加環境變數來解決(未測試,因為supervisor服務自啟動的需要不是很強烈):
[Service]
environment=PYTHONPATH=/opt/mypypath:%(ENV_PYTHONPATH)s,PATH=/opt/mypath:%(ENV_PATH)s

參考:https://github.com/Supervisor/initscripts
參考:53203991
參考:https://www.cnblogs.com/mhc-fly/p/8512491.html
參考:http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

systemd下supervisord服務開機自啟動以及注意事項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.