This is a creation in Article, where the information may have evolved or changed.
Supervisor is a UNIX system process management software that can be used to manage Apache, Nginx and other services, if the service hangs can let them automatically restart. The following is based on the CentOS 6.6, which describes the following specific implementation:
sudo listen to Yum listen to the install listen to Python-setuptoolssudo listen to Easy_install listen to supervisor
If you do not see any error, then the installation is successful, you can use echo_supervisord_conf to view configuration details, and then generate the configuration file.
sudo listen to echo_supervisord_conf listen > Listen to/etc/supervisord.conf
Suppose the following is a simple Golang code:
package
mainHear
import
(
聽聽聽聽
"fmt"
聽聽聽聽
"log"
聽聽聽聽
"net/http"
)Hear
func
main() {
聽聽聽聽
http.HandleFunc(
"/"
,聽
func
(w http.ResponseWriter, r *http.Request) {
聽聽聽聽聽聽聽聽
fmt.Fprintf(w,聽
"Hello world"
)
聽聽聽聽
})Hear
聽聽聽聽
err := http.ListenAndServe(
":9090"
, nil)
聽聽聽聽
if
err != nil {
聽聽聽聽聽聽聽聽
log.Fatal(
"ListenAndServe: "
, err)
聽聽聽聽
}
}
Go build compiles the executable file test in/usr/local/ponpon/gowork/src/test/.
Edit/etc/supervisord.conf, add run program settings at the end
[program:go-http-server]command=/usr/local/ponpon/gowork/src/test/testdirectory=/usr/local/ponpon/gowork/src/ testautostart=trueautorestart=truestartsecs=10stdout_logfile=/var/log/stdout.logstdout_logfile_maxbytes= 1mbstdout_logfile_backups=10stdout_capture_maxbytes=1mbstderr_logfile=/var/log/stderr.logstderr_logfile_ Maxbytes=1mbstderr_logfile_backups=10stderr_capture_maxbytes=1mb
Several configuration instructions:
Command: Indicates the running commands, fill in the full path.
Directory: Represents the CD to the app's catalog
Autostart: Indicates whether to start with supervisor.
AutoRestart: If the program is hung, restart it.
Stdout_logfile: Terminal standard output redirection file.
Stderr_logfile: Terminal error output redirect file.
Finally start supervisor
sudo listen/usr/bin/supervisord listen to-C listen to/etc/supervisord.conf
If prompted/tmp/supervisord.sock error, delete /tmp/supervisord.sock restart supervisor can
This article is from the "Programming in XMU" blog, be sure to keep this source http://liuxp0827.blog.51cto.com/5013343/1643620