Supervisor is a very good daemon management tool. It has a series of powerful features such as automatic startup, log output, automatic log cutting, etc. The following is a record of installing and using Supervisor under CentOS. Install # epel source yum install epel-release # Install supervisor yum install -y supervisor # Start automatically at boot time systemctl enable supervisord # Start the supervisord service systemctl start supervisord Bash Configuration Path # Main configuration file /etc/supervisord.conf # Run the program configuration folder /etc/supervisord.d/ Bash Operation Command systemctl stop supervisord systemctl start supervisord systemctl status supervisord # Reload the configuration file without affecting the running program systemctl reload supervisord systemctl restart supervisord Bash Use Test Write a test script test.php to record the number of startups and runs. <?php try { $a = file_get_contents('./times.json'); } catch (Exception $e) { $a = 0; } $a++; file_put_contents('./times.json', $a); echo date('Ymd H:i:s') . " This is the {$a}th start!!!!" . PHP_EOL; $i = 1; while (1) { echo date('Ymd H:i:s') . "{$i}th output" . PHP_EOL; $i++; sleep(5); } PHP Add test.ini in the program configuration folder [program:test] directory=/home/wwwroot/test.cc command=php test.php autostart=true autorestart=true stderr_logfile=/home/wwwroot/test.cc/log/error.log stdout_logfile=/home/wwwroot/test.cc/log/out.log Ini The above are just some necessary basic configurations. For more detailed configuration reference: ;[program:theprogramname] ;command=/bin/cat ; the program (relative uses PATH, can take args) ;process_name=%(program_name)s ; process_name expr (default %(program_name)s) ;numprocs=1 ; number of processes copies to start (def 1) ;directory=/tmp ; directory to cwd to before exec (def no cwd) ;umask=022 ; umask for process (default None) ;priority=999 ; the relative start priority (default 999) ;autostart=true ; start at supervisord start (default: true) ;autorestart=true ; retstart at unexpected quit (default: true) ;startsecs=10 ; number of secs prog must stay running (def. 1) ;startretries=3 ; max # of serial start failures (default 3) ;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2) ;stopsignal=QUIT ; signal used to kill process (default TERM) ;stopwaitsecs=10 ; max num secs to wait for b4 SIGKILL (default 10) ;user=chrism ; setuid to this UNIX account to run the program ;redirect_stderr=true ; redirect proc stderr to stdout (default false) ;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO ;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) ;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) ;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0) ;stdout_events_enabled=false ; emit events on stdout writes (default false) ;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO ;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) ;stderr_logfile_backups=10 ; # of stderr logfile backups (default 10) ;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0) ;stderr_events_enabled=false ; emit events on stderr writes (default false) ;environment=A=1,B=2 ; process environment additions (def no adds) ;serverurl=AUTO ; override serverurl computation (childutils) Ini Run the restart or reload configuration command to load the new configuration: systemctl restart supervisord systemctl reload supervisord Bash View the process: [root@localhost test.cc]# ps -aux | grep test.php root 22277 0.0 0.6 269732 12124 ? S 17:38 0:00 php test.php root 22335 0.0 0.0 112712 996 pts/0 S+ 17:41 0:00 grep --color=auto test.php Bash You can restart the server, or Regarding the configuration, take a closer look at the reference above, which basically covers the required functions, multi-process operation, log cutting size, retention quantity, etc. It is powerful and easy to use. For more advanced features, please refer to Summarize The above is the installation, configuration and use of the process daemon supervisor in Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Angular performance optimization: third-party components and lazy loading technology
>>: Mysql query the most recent record of the sql statement (optimization)
Copy code The code is as follows: <iframe id=&...
Effect picture: Implementation code: <template...
When it comes to <fieldset> and <legend&...
one. First of all, you have to package it in idea...
Table of contents Preface: System Requirements: I...
1. Download 1. Download the installation package ...
Today I looked at some things related to data bac...
This article uses examples to illustrate how to i...
You must have saved other people’s web pages and l...
Table of contents Preface 1. Application componen...
During the project optimization today, MySQL had ...
SQL statement DROP TRIGGER IF EXISTS sys_menu_edi...
Install pymysql pip install pymysql 2|0Using pymy...
Table of contents 1. Install vue-video-player 2. ...
The CSS3 category menu effects are as follows: HT...