. NET Core+centos Deployment +supervisor Daemon

Source: Internet
Author: User

Tag: Lock Guardian requires signature repos key ATI name SPI

First, install. Netcore and publishing projects
1. To start installing. NET, you need to register your Microsoft signing key and add a Microsoft product feed. This only needs to be done once per machine. Open a command prompt and run the following command
sudo rpm--import https://packages.microsoft.com/keys/microsoft.asc
sudo sh-c ' echo-e ' [Packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl= https:// packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https:// Packages.microsoft.com/keys/microsoft.asc ">/etc/yum.repos.d/dotnetdev.repo"
2. Update Yum:
sudo yum update

3. Installation dependence:
sudo yum install libunwind Libicu
4. Install the. Net Core SDK:
(1), first to see which versions of the SKD
sudo yum search dotnet-sdk

(2) Installation:
sudo yum install dotnet-sdk-2.1.200.x86_64
5. Check if the installation is successful:
Dotnet--version
6. Create a project
dotnet New MVC WebDev
7. Running the project
Dotnet run, where you can access it, by default, using http://localhost:5000
If the execution succeeds, you can perform the following steps
8. Publish the project:
dotnet Publish default project will be published to./bin/debug/netcoreapp2.1/publish (netcoreapp2.1 is the version of my SDK) directory
9. Go to the Publish directory and execute the command:
Dotnete WebDev.dll, it will execute successfully, direct access
http://localhost:5000, indicating successful release
Second, installation Nignx:
Curl-o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
RPM-IVH nginx.rpm
Yum Install Nginx
Input:systemctl start Nginx to start Nginx.
Input:systemctl enable Nginx to set the Nginx boot (Linux downtime, restart will automatically run Nginx does not need to connect to enter the command).
Third, configure the firewall:

command: Firewall-cmd--zone=public--add-port=80/tcp--permanent(Open 80 port)

command: systemctl restart Firewalld(Restart the firewall for immediate configuration)
Iv. Configuring Nginx forwarding for ASP.
Modify/etc/nginx/conf.d/default.confFile
Replace the contents of the file with
server {
Listen 80;
Location/{
Proxy_pass http://localhost:5000;
Proxy_http_version 1.1;
Proxy_set_header Upgrade $http _upgrade;
Proxy_set_header Connection keep-alive;
Proxy_set_header Host $host;
Proxy_cache_bypass $http _upgrade;
}
}
Execution:nginx–s reload make it effective immediately

Command: dotnet
/bin/debug/netcoreapp2.1/publish/  WebApplication1.dll

To here,. Netcore deployment has been completed;
Iv. Configuring the Daemon Service (Supervisor)

Supervisor's introduction See: Https://www.studyscript.com/Post/index/id/3038.html

1, installation Supervisor

#yum install python-setuptools  //安装python安装工具#easy_install supervisor  //安装supervisor

2. Generate Supervisor Configuration file

Create a directory and give the owner readable, writable, executable (700) permissions

#mkdir -m 700 -p /etc/supervisor

3. Create a configuration file

#echo_supervisord_conf > /etc/supervisor/supervisord.conf

4. Modify the configuration file

#vim /etc/supervisor/supervisord.conf

At the end of the document add

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

5. Create a process configuration file

5.1 Creating a process configuration file to store a directory

  #mkdir -m 700 /etc/supervisor/conf.d

5.2. Create a process configuration file

  #vim /etc/supervisor/conf.d/IO_Spider_WebAPI.conf

Edit Content

[Program:io_spider_webapi]
Command=/bin/bash-c "Dotnet Xxgk.dll"
directory=/home/zhangfei/io_spider/webapi/
Autorestart=true
Stderr_logfile=/var/log/io_spider_webapi.error.log
Stdout_logfile=/var/log/io_spider_webapi.stdout.log
Environment=aspnetcore_environment=development
User=root
Stopsignal=int

6. Create Supervisor self-starting service

6.1. Create a service file

  #vim /lib/systemd/system/supervisor.service

6.2. Editorial content

[Unit]
Description=supervisor
[Service]
Type=forking
Execstart=/usr/bin/supervisord-c/etc/supervisor/supervisord.conf
Execstop=/usr/bin/supervisorctl shutdown
Execreload=/usr/bin/supervisorctl Reload
Killmode=process
Restart=on-failure
Restartsec=42s
[Install]
Wantedby=multi-user.target

7. Empowering

#chmod 754 /lib/systemd/system/supervisor.service

8. Set Boot from boot

#systemctl enable supervisor.service

9. Operation Service

#systemctl start supervisor.service

10. View Process Execution Status

#supervisorctl

11. Enter the "status" view after entering the supervisor prompt, or#supervisorctl status




. NET Core+centos Deployment +supervisor Daemon

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.