2014年7月26日 星期六

筆記:把玩 supervisord


本文是從 evernote 筆記中轉存出來的文章,分享於 Tainan.py x MOSUT 2014.07 




# 看完了 wen 分享的文章以後 …




# 也來試看看用 python 寫的 [老字號] supervisor 吧 (推薦用來管理自己的 process)






# 安裝(盡量在 virtualenv 之外裝) 
pip install supervisor --pre


# 建立 config sample file

echo_supervisord_conf  >  /etc/supervisord.conf


# 修改 config file

[program:foo]
command=/bin/cat


# 建議啟動時讀取自己的 config file

supervisord -c supervisord.conf


# 使用 supervisorctl 來管理自己的 process (使用範例)

[tainanpy etc]$ supervisorctl

backup                           RUNNING    pid 26703, uptime 26 days, 18:18:33
main                               RUNNING    pid 26702, uptime 26 days, 18:18:33
sentry-web                    RUNNING    pid 26701, uptime 26 days, 18:18:33



supervisor> ?

default commands (type help <topic>):
=====================================
add    clear  fg        open  quit    remove  restart   start   stop  update
avail  exit   maintail  pid   reload  reread  shutdown  status  tail  version



supervisor> restart sentry-web

sentry-web: stopped
sentry-web: started



supervisor> status main

main                             RUNNING    pid 26702, uptime 26 days, 18:19:42
supervisor>


# 其實啟動時可以帶很多參數,config 檔支援 *更多* 設置方式


-c FILE, --configuration=FILE
  The path to a supervisord configuration file.
-n, --nodaemon Run supervisord in the foreground.
-h, --help Show supervisord command help.
-u USER, --user=USER
  UNIX username or numeric user id. If supervisord is started as the root user, setuid to this user as soon as possible during startup.
-m OCTAL, --umask=OCTAL
  Octal number (e.g. 022) representing the umask that should be used by supervisord after it starts.
-d PATH, --directory=PATH
  When supervisord is run as a daemon, cd to this directory before daemonizing.
-l FILE, --logfile=FILE
  Filename path to use as the supervisord activity log.
-y BYTES, --logfile_maxbytes=BYTES
  Max size of the supervisord activity log file before a rotation occurs. The value is suffix-multiplied, e.g “1” is one byte, “1MB” is 1 megabyte, “1GB” is 1 gigabyte.
-y NUM, --logfile_backups=NUM
  Number of backup copies of the supervisord activity log to keep around. Each logfile will be of size logfile_maxbytes.
-e LEVEL, --loglevel=LEVEL
  The logging level at which supervisor should write to the activity log. Valid levels are tracedebuginfowarnerror, and critical.
-j FILE, --pidfile=FILE
  The filename to which supervisord should write its pid file.
-i STRING, --identifier=STRING
  Arbitrary string identifier exposed by various client UIs for this instance of supervisor.
-q PATH, --childlogdir=PATH
  A path to a directory (it must already exist) where supervisor will write its AUTO -mode child process logs.
-k, --nocleanup
  Prevent supervisord from performing cleanup (removal of old AUTO process log files) at startup.
-a NUM, --minfds=NUM
  The minimum number of file descriptors that must be available to the supervisord process before it will start successfully.
-t, --strip_ansi
  Strip ANSI escape sequences from all child log process.
-v, --version Print the supervisord version number out to stdout and exit.
--profile_options=LIST
  Comma-separated options list for profiling. Causes supervisord to run under a profiler, and output results based on the options, which is a comma-separated list of the following: cumulativecallscallers. E.g. cumulative,callers.
--minprocs=NUM The minimum number of OS process slots that must be available to the supervisord process before it will start successfully.
supervisorctl Command-Line Options

-c, --configuration
  Configuration file path (default /etc/supervisord.conf)
-h, --help Print usage message and exit
-i, --interactive
  Start an interactive shell after executing commands
-s, --serverurl URL
  URL on which supervisord server is listening (default “http://localhost:9001”).
-u, --username Username to use for authentication with server
-p, --password Password to use for authentication with server
-r, --history-file
  Keep a readline history (if readline is available) 





autorestart
May be one of falseunexpected, or true. If false, the process will never be autorestarted. Ifunexpected, the process will be restart when the program exits with an exit code that is not one of the exit codes associated with this process’ configuration (see exitcodes). If true, the process will be unconditionally restarted when it exits, without regard to its exit code.
Default: unexpected
Required: No.
Introduced: 3.0


# 官網


Try it !


(文件 Host 在 Readthedocs <- 三月份若渴:來分享的外國朋友創辦的服務)





1 則留言:

  1. Joe.Dev 的 Loser 部落格: 筆記:把玩 Supervisord >>>>> Download Now

    >>>>> Download Full

    Joe.Dev 的 Loser 部落格: 筆記:把玩 Supervisord >>>>> Download LINK

    >>>>> Download Now

    Joe.Dev 的 Loser 部落格: 筆記:把玩 Supervisord >>>>> Download Full

    >>>>> Download LINK

    回覆刪除