Install a supervisor on centos to manage applications such as dotnetcore.

Source: Internet
Author: User
Tags dotnet

Install a supervisor on centos to manage applications such as dotnetcore.

Supervisor introduction:

  This is a process management tool written in python. It can guard all processes managed by it and prevent abnormal exit. It also provides a visual web interface for manual management, enabling, disabling, and restarting various applications, the interface is as follows:

About Installing a supervisor on centos:

1. Install yum:

yum install supervisor

2. Configure the supervisor:

We will use vim to edit the/etc/supervisord. conf file. We can see that there are many options

 

The first node is UnixSocket, which communicates between unix processes. It is enabled by default. The supervisorctl of the local machine can be used to connect to the supervisord server.

The second node is the external Http service, which is open to the outside, mainly for remote supervisorctl or client browser access. Of course, the local supervisorctl can also be connected through http.

The third node is the core, and the supervisord service is the worker that truly manages processes. Each option comment in it is explained.

The fourth node is the local client, supervisorctl. The figure uses unixsocket to communicate with supervisord. We can use some commands to control supervisord, such as supervisorctl reload // reload supervisord, that is, restart the instance. supervisorctl update is the configuration update information. supervisorctl start {process name} is started, supervisorctl stop {process name} is disabled, and so on.

First, we start the supervisor service:

supervisord -c /etc/supervisord.conf

In this way, the supervisor service is started using this configuration file,

At this time, we can access this page through port 9001 to see the page of the first figure without a task list

Step 1 is complete. Next we will run a program in it.

First install a dotnetcore,

Https://dotnet.github.io/here is an introduction,

Then we create a core' program and place it in the/service/helloword directory.

Compile one in dotnet and generate a dll file.

Go to the dotnet WebApplication1.dll directory.

Run successfully. Then we enable supervisord. conf to continue the configuration,

There are two main configurations: directory and command. directory is the directory cd first, command is to execute this command, and environment ,. net can be configured here for general production environments, development environments, and test environments.

Save the file

Reload supervisord

When I opened the browser, did I find another running helloworld program?

You can restart, disable, and run tail-f to view Real-time log information.

Now let's test what happens after the program is shut down abnormally. Open the log and kill the process in the console. The log is displayed.

Supervisord automatically opens it, So supervisord can also guard this process,

Therefore, we can consider. the netcore program is deployed on a linux server and managed using supervisord, which is equivalent to a service on windows. It also monitors the running status and logs in real time, it is also convenient to switch freely.

 

This tool is not only used to manage the dotnetcore program, but many other programs can be managed. However, it must be noted that the managed program must be run in a non-deamon mode, otherwise, he cannot accurately capture the process Id, and the captured process id will be disabled when deamon is started.

As a result, 1. When started, the startup was successful, but after the process exited again, he thought that the program was exited abnormally and then restarted continuously. 2. Naturally, the system could not be controlled.

 

 

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.