Introduction to installation and use of Linux supervisor---SuSE

Source: Internet
Author: User
Tags dotnet socket error

In Linux or Unix operating systems, the daemon (Daemon) is a special process that runs in the background, independent of the control terminal and periodically performs some sort of task or waits for certain occurrences to be handled. Because in Linux, each system communicates with the user interface called the terminal, every process that starts from this terminal is attached to this terminal, this terminal is called the control terminal of these processes, when the control terminal is closed, the corresponding process will automatically shut down. However, the daemon can break this limit, it is out of the terminal and runs in the background, and it is out of the terminal to avoid the process of information in the process of running in any terminal and the process will not be interrupted by terminal information generated by any terminal. It starts running from the time it was executed until the entire system shuts down before exiting.

The creation daemon here refers to the host process that publishes the dotnet Xxx.dll command of the ASP. NET core program on Linux to create a daemon.

There are a lot of tools on Linux that can manage processes, and we use Supervisor to do it. There are two reasons:

1, it is the official Microsoft document recommended, reduce the cost of learning.

2, it is not necessarily the best, but it must be the most complete document.

Supervisor, developed in Python (2.4+), is a client/server system that allows users to manage Unix-based system processes, providing a number of features to manage processes.

Official Document: http://supervisord.org/

Official document: http://supervisord.org/configuration.html--config Configuration

There are currently three issues

Problem 1:asp.net core applications run in the shell, and if you close the shell you will find that the ASP. NET core application is turned off, which makes the app inaccessible, which is certainly not what we want to encounter, and the production environment is 0 tolerant of this situation.

Issue 2: If the ASP. NET core process terminates unexpectedly, it is often not timely to have to start the shell again.

Issue 3: If the server is down or needs to be restarted we still need to connect to the shell to boot.

To solve this problem, we need to have a program to monitor the status of the ASP. Restart immediately when the application stops running.

The operation is as follows:

1. Install Supervisor to SuSE system

Execute the following command:

Install Python

sudo zypper in Python-pip

sudo pip install-u setuptools

Pip Install Supervisor

Or

If Easy_install is not good, download from the official: wget https://pypi.python.org/packages/80/37/ 964c0d53cbd328796b1aeb7abea4c0f7b0e8c7197ea9b0b9967b7d004def/supervisor-3.3.1.tar.gz then install via python: Tar zxf SUPERVISOR-3.3.1.TAR.GZCD Supervisorpython setup.py Install

Error may occur:

    1. Tip Setuptools-0.6c11.tar Not installed
      Download Https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gztar zxf SETUPTOOLS-0.6C11.TAR.GZCD setuptools-0.6c11/python setup.py buildpython setup.py  Install
    2. Prompt for download error, need meld3>0.6.5
      1. Download http://dl.fedoraproject.org/pub/epel/7/x86_64/p/python-meld3-0.6.10-1.el7.x86_64.rpm (or I backed up a copy)
      2. Installing RPM-IVH python-meld3-0.6.10-1.el7.x86_64.rpm

The following prompts, installation complete:

12 Using /usr/lib64/python2.7/site-packagesFinished processing dependencies forsupervisor==3.3.1

2, configuration supervisor

A. Creating folders and configuration Files

mkdir/etc/supervisorecho_supervisord_conf >/etc/supervisor/supervisord.conf

B. Modify the contents of a /etc/supervisor/supervisord.conf file

At the end of file [include] node

to put; files = Relative/directory/*.ini

Change to Files =/etc/supervisor/conf.d/*.conf

[include]
Files =/etc/supervisor/conf.d/*.conf

c. Execute the supervisorctl reload command to make the configuration file effective (if not, continue execution, followed by a specific workaround).

d. in/etc/supervisor/ under Create CONF.D folders, and projectname.conf ( named after the project name)

E. Open projectname.conf file, add the following:



Note: Remove the Chinese notes from the back of the # when saving

Save and exit

3. Run Supervisord to see if it takes effect, execute the following command:

Supervisord-c/etc/supervisor/supervisord.confps-ef | grep ProjectName

Return

Root     27007 27006  1 13:21?        00:00:02 dotnet ProjectName.dll root     27026 26810  0 13:23 pts/0    00:00:00 grep--color=auto ProjectName

Indicates a successful run!

Browser Access site ...

Note: The following message appears when you execute the first command:

Error:another program was already listening on a port the one of our HTTP servers are configured to use.  Shut This program down first before starting Supervisord. For help, Use/usr/bin/supervisord–h

Because there is an application running with the supervisor configuration, you need to execute the SUPERVISORCTL shutdown command to terminate it, or recreate a projectname.conf file to execute the first command.

The following error occurs if you run Supervisorctl

Error: <class ' Socket.error ';, [Errno 111] Connection refused:file:/usr/lib64/python2.6/socket.py line:567

It may be because the Supervisord process is stopped and it is recommended to rerun

sudo supervisord-c/etc/supervisor/supervisord.confsudo supervisorctl-c/etc/supervisor/supervisord.conf

4. Common Commands

123456789 sudo service supervisor stop 停止supervisor服务sudo service supervisor start 启动supervisor服务 supervisorctl shutdown #关闭所有任务 supervisorctl stop|start program_name #启动或停止服务supervisorctl status #查看所有任务状态

  

5. Configure Supervisord Boot up

A. create a file under the specified directory Supervisord.service

Vim/usr/lib/systemd/system/supervisord.service

B. Enter the following:

Save and exit  

Execute the following command:

Systemctl Enable Supervisord

Tips:

Created symlink From/etc/systemd/system/multi-user.target.wants/supervisord.service to/usr/lib/systemd/system/ Supervisord.service.

Verify that the boot is on:

Systemctl is-enabled Supervisord

Tips:

Enabled

Indicates a successful setup!

Now , create the supervisor The daemon is complete.

Original link: https://www.cnblogs.com/Hai--D/p/5820718.html

If there is a problem with the above procedure,

For example:

No such file or directory:file:/usr/lib64/python2.7/socket.py line:228

or socket error, etc.

You can refer to the following file operations:

1, Structure: etc have folder supervisor, folder supervisor below contains two, one is Conf.d folder and supervisord.conf file

2,supervisord.conf file specific content

; Sample Supervisor config file.
;
; For more information in the config file, please see:
; Http://supervisord.org/configuration.html

[Unix_http_server]
File=/var/run/supervisor.sock; The path to the socket file
chmod=0700; Socket file Mode (default 0700)

[Supervisord]
Logfile=/var/log/supervisor/supervisord.log; Main log file; Default $CWD/supervisord.log
LOGFILE_MAXBYTES=50MB; Max main logfile bytes b4 rotation; Default 50MB
logfile_backups=10; # of main logfile backups; 0 means none, default 10
Loglevel=info; Log level; Default info; Others:debug,warn,trace
Pidfile=/var/run/supervisord.pid; Supervisord Pidfile; Default Supervisord.pid


[Rpcinterface:supervisor]
Supervisor.rpcinterface_factory = Supervisor.rpcinterface:make_main_rpcinterface

; The Supervisorctl section configures how Supervisorctl would connect to
; Supervisord. Configure it match the settings in either the Unix_http_server
; or Inet_http_server section.

[Supervisorctl]
Serverurl=unix:///var/run/supervisor.sock; Use a unix://URL for a UNIX socket

; The [include] section can just contain the "files" setting. This
; Setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames is
; interpreted as relative to the this file. Included Files *cannot*
; Include files themselves.

[include]
Files =/etc/supervisor/conf.d/*.conf

Note : If the file is/ tmp all swap/var/run or /var/log

3,conf.d folder is a custom file such as mmpscore.conf

The specific contents are as follows:

[Program:mmps]
Command=dotnet MmPS.dll
directory=/home/linjie/Desktop/suse Linux Enterprise Server SP2 64-bit
Environment=aspnetcore__environment=production
Stopsignal=int
Autostart=true
Autorestart=true
Startsecs=1
Stderr_logfile=/var/log/mmps.err.log
Stdout_logfile=/var/log/mmps.out.log

4, if the whole operation after the document and the contents of the same with the above, or there is a problem,

Perform:

sudo supervisord-c/etc/supervisor/supervisord.conf

sudo supervisorctl-c/etc/supervisor/supervisord.conf

Basically will be solved.

Introduction to installation and use of Linux supervisor---SuSE

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.