Home >Backend Development >Golang >Let's talk about Golang process guardian Supervisor

Let's talk about Golang process guardian Supervisor

藏色散人
藏色散人forward
2021-09-16 14:57:093114browse

This article is written by the go language tutorial column to talk about the Golang process guardian Supervisor. I hope it will be helpful to friends in need!

Let's talk about Golang process guardian Supervisor

1. Install Supervisor

Install supervisor

2. Generate Golang executable program

Enter the golang project root directory cd /data/go/test, run go build -o main main.go to generate an executable program, optional: then use upx main to compress

3. Edit the configuration file of supervisor go

  • Key point: command value "must" absolute path

  • Key point: directory value [Required] configuration (required when there is a configuration file ending with non-go)
    I saw many articles on the Internet that can be successfully started without configuring the directory. After investigation and review of information, it was determined that the function of the directory is to start the main program. , switch to this directory and look for the configuration file directory of the main program. If there is a configuration file with a non-go ending in the project, this directory is a "must" configuration. Directory role: the configuration file directory when the main program starts

    [program:go];process_name=%(program_name)s_%(process_num)02d; command 值『必须』为绝对路径command=/data/go/test/mainautostart=trueautorestart=trueuser=rootnumprocs=1redirect_stderr=truestdout_logfile=/var/log/supervisor/go.logdirectory=/data/go/test

    If there is a better way for supervisor to configure golang or other welcome messages

More golang related knowledge, Please visit golangtutorial column!

The above is the detailed content of Let's talk about Golang process guardian Supervisor. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete