My name is: yashar esmaildokht
I am Gnu/Linux Sys/net/sec Admin & Oracle
Dba
my tel : 09141100257
my resume (fa) :goo.gl/oUQopW
Linkedin: goo.gl/Ljb9SF
website :
http://unixmen.ir
http://oraclegeek.ir
http://webmom.ir
my nick name : royaflash
Supervisorکنترل و مانیتوراجازه سیستم کاربران به که باشد می سرور کلینت سیستم یک/
روی بر ها سرویس کنترل روال اینکه از فارغ .دهد می را لینوکسی سیستم یک روی بر ها پروسس
،باشد نحو چه به شما لینوکسی توزیعsupervisorتوزیع هر روی بر یکسان بصورت تواند می
.نماید دهی سرویس شما به ثابتی شکل به لینوکسی
: کرد اشاره زیر موارد به توان می برنامه های قابلیت از
.It can be confgured to automatically restart processes on a crash
It can start processes on its own invocation.
Processes can be grouped into “process groups” and a set of logically related processes can be
stopped and started as a unit.
allows to assign priorities to processes and allows user to start/restart all processes via the
supervisorctl client which starts them in the preassigned priority order.
It also provides password protected web user-interface through which all the processes managed by
supervisor can be stopped/started/restarted when needed.
کتابخانه نصب
کتابخانه نصب برایsupervisordاجرا خود لینوکسی توزیع نوع اساس بر را زیر دستورات از یکی
.نمایید
فدورا
# yum install supervisor
: دبیان
# apt-get install supervisord
امکانات برخی
•شبه فایل یک در تنظیمات )کلیه .استفاده در سهولتini(عموم برای فهم قابل زبان به
•.ها پروسس کلیه متمرکز مدیریت
•.لینوکسی های سیستم کلیه با سازگار
•اپلیکیشنsupervisorctlبصورت کهcommand-lineپروسس کلیه کنترلر و مانیتور امکان
.سازد می فراهم را ها
•.اولویت با همراه ها برنامه اجرای
•.خودکار اجرای ،ها برنامه مجدد اجرای کنترل
پروسس یک اجرای
#supervisorctl start myApp
:myApp started
راهاندازیپروسس یک مجدد
# supervisorctl restart myApp
:myApp restarted
برنامه به و ایجاد را زیر اسکریپت ما نمونه برایsupervisorدهیم می:
/usr/local/bin/long.sh :
#!/bin/bash
while true
do
# Echo current date to stdout
echo `date`
# Echo 'error!' to stderr
echo 'error!' >&2
sleep 1
done
chmod +x /usr/local/bin/long.sh
: مربوطه تنظیمات حال
. ./etc/supervisor/conf d/long_script conf
:[program long_script]
.command=/usr/local/bin/long sh
autostart=true
autorestart=true
. .stderr_logfle=/var/log/long err log
. .stdout_logfle=/var/log/long out log
: برنامه رفرش برای
supervisorctl reread
21.
supervisorctl update
کنسولsupervisor:
$ supervisorctl
long_scriptRUNNING pid 12614, uptime 1:49:37
supervisor>
supervisor> help
default commands (type help ):
=====================================
add clear fg open quit remove restart start stop update
avail exit maintail pid reload reread shutdown status tail version
supervisor> stop long_script
long_script: stopped
supervisor> start long_script
long_script: started
supervisor> restart long_script
long_script: stopped
long_script: started
supervisor> tail long_script
Sun Jul 21 00:36:10 UTC 2013
Sun Jul 21 00:36:11 UTC 2013
Sun Jul 21 00:36:12 UTC 2013
Sun Jul 21 00:36:13 UTC 2013
Sun Jul 21 00:36:14 UTC 2013
Sun Jul 21 00:36:15 UTC 2013
Sun Jul 21 00:36:17 UTC 2013
supervisor> tail long_script stderr
error!
error!
error!
error!
error!
error!
error!
22.
: داریم رازیر ساختار کلی صورت به
:[program program_one]
.command=node server js .;command to be executed, ‘node server js ‘ is
.example for running a nodejs server
numprocs=1 ( ).;number of processes copies to start default 1
directory=<path to command>
.stdout_logfle=/var/log/supervisor/program_one log
autostart=true ( : );start at supervisord start default true
autorestart=true ( : );whether/when to restart default unexpected
user=root .;setuid to this UNIX account to run the program
stopsignal=KILL ( ).;signal used to kill process default TERM
startretries=10 ( ).;max # of serial start failures default 3
• .Below command is to start the program
supervisorctl start program_one
23.
: کنید اضافهرا ها ساختار گروهی بصورت توانید می شما
Add a Group in supervisord.conf file in below format to run processes as group and
to be controlled as group by supervisor
[group:group1]
programs=program_one, program_two ; Add program names to run as a group
priority=999 ; setup priority of the group to run
• Below command is to start the programs in a group.
supervisorctl start <groupname>:*
supervisorctl start group1:*
24.
وب تحت قابلیتکردن فعال برایsupervisorفایل به تنظیمات فایل در زیررا خطوطsupervisord.conf
: کنید اضافه
[inet_http_server]
port=0.0.0.0:9001 ;Give any port number which is not already in use.
username=<username> ;Give username using which you access web user-interface.
password=<password> ;Give password using which you access web user-interface.
. کنیم می ریستارت را سرویس سپس
service supervisor restart
مسیر درhttp://localhost:9001/باشد می دسترس در حال
25.
: گیری نتیجه
:باشد می زیر صورت به برنامه کلی ساختار
To start, restart and stop supervisor:
sudo service supervisor start
sudo service supervisor restart
sudo service supervisor stop
• To list all programs of supervisor with status:
supervisorctl
• To start, restart and stop all programs of supervisor:
supervisorctl start all
supervisorctl restart all
supervisorctl stop all
• To start, restart and stop specific programs of supervisor:
supervisorctl start program_one
supervisorctl restart program_one
supervisorctl stop program_one
• To start, restart and stop all programs defined in a group:
supervisorctl start <groupname>:*
supervisorctl restart <groupname>:*
supervisorctl sttop <groupname>:*