zoukankan      html  css  js  c++  java
  • supervisor管理python程序

    1. 下载supervisor

        0 16:47:26 root@test,172.16.1.12:~ # yum -y install supervisor
      
    2. 配置supervisor

        0 16:49:51 root@test,172.16.1.12:~ # cp /etc/supervisord.conf{,.bak}
        0 16:50:14 root@test,172.16.1.12:~ # vim /etc/supervisord.conf
      [unix_http_server]
      file=/server/data/supervisord/supervisor.sock   ; the path to the socket file
      
      [supervisord]
      logfile=/server/logs/supervisord/supervisord.log ; main log file; default $CWD/supervisord.log
      logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
      logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
      loglevel=info                ; log level; default info; others: debug,warn,trace
      pidfile=/server/data/supervisord/supervisord.pid ; supervisord pidfile; default supervisord.pid
      nodaemon=false               ; start in foreground if true; default false
      minfds=1024                  ; min. avail startup file descriptors; default 1024
      minprocs=200                 ; min. avail process descriptors;default 200
      
      [rpcinterface:supervisor]
      supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
      
      [supervisorctl]
      serverurl=unix:///server/data/supervisord/supervisor.sock ; use a unix:// URL  for a unix socket
      
      [include]
      files = /etc/supervisord.d/*.conf
      
    3. 启动supervisor

        0 16:52:09 root@test,172.16.1.12:~ # mkdir -p /server/data/supervisord /server/logs/supervisord
        0 16:53:04 root@test,172.16.1.12:~ # systemctl start supervisord.service 
        0 16:55:00 root@test,172.16.1.12:~ # systemctl enable supervisord.service
      
    4. 管理一个python程序。

        0 16:55:33 root@test,172.16.1.12:~ # vim /etc/supervisord.d/backend.conf
      [program:backend]
      
      directory=/datas/app/platform/backend
      command=/datas/app/platform/backend/venv/bin/python manage.py runserver 0.0.0.0:8000
      autorestart=true
      
    5. 加载配置自动启动。

        0 17:03:01 root@test,172.16.1.12:/etc/supervisord.d # supervisorctl reload
      Restarted supervisord
        0 17:03:06 root@test,172.16.1.12:/etc/supervisord.d # supervisorctl status
      backend                          RUNNING   pid 256117, uptime 0:00:02
      


    写作不易,转载请注明出处,谢谢~~

  • 相关阅读:
    Java反射机制
    两个port贴合七夕主题,百度输入法的“情感营销”策略
    2014年百度之星程序设计大赛
    Java内存模型
    远程推送
    【NOI2010】海拔【平面图最小割】
    句法模式识别(二)-正规文法、上下文无关文法
    通过c# 实现mysql 数据库的备份和附加
    时光轴二之RecyclerView版时光轴效果
    手游产品经理初探(四)从Buybutton谈玩家付费
  • 原文地址:https://www.cnblogs.com/ccbloom/p/15119664.html
Copyright © 2011-2022 走看看