1. 程式人生 > 實用技巧 >dotnet on centos 7 日常維護

dotnet on centos 7 日常維護

1.檢視程序

 ps -aux |grep dotnet

2.殺dotnet程序

命令:kill 程序ID

 kill 21887

3.修改 dotnet supervisor 配置

3.1. 修改 /etc/supervisor/supervisord.conf,在最後面加上如下命令(將/etc/supervisor/conf.d/ 下面的配置都包含進去)

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

3.2. 在/etc/supervisor/conf.d/ 下面建立dotnet配置,寫入下列命令列

[program:ylhcms.dll]
command
=/bin/bash -c "dotnet ylhcms.dll" directory=/usr/local/ylhcms/ autorestart=true stderr_logfile=/var/log/ylhcms.dll.err.log stdout_logfile=/var/log/ylhcms.dll.out.log environment=ASPNETCORE_ENVIRONMENT=Production user=root opsignal=INT autostart=true autorestarti=true startsecs=3

4.啟動和檢視,重新啟動supervisor 守護程序--啟動supervisor

--啟動所有的被守護程序(/etc/supervisor/conf.d/下面的程序)
supervisord -c /etc/supervisor/supervisord.conf


--檢視 執行狀態
supervisorctl status


--關閉 一個被守護程序

supervisorctl stop ylhcms.dll


--開啟 一個被守護程序
supervisorctl start ylhcms.dll

--檢視 supervisor程序ID,獲取到 程序ID 12288

ps -aux | grep supervisord

--根據程序ID 殺程序 supervisord

kill 12288

5.程式碼部署(獨立環境釋出)

釋出打包之後,壓縮成.zip格式,"rz" 上傳,解壓縮至 /user/local/ylhcms 下面

rz 

unzip ylhcms.zip

6.修改Nginx站點配置資訊

vim /usr/local/nginx/conf/nginx.conf
server {
  listen 80;
  server_name www.xx.com;
  # root /usr/local/ylhcms/;
  location ~.*(js|css|svg)$ {
      root /usr/local/ylhcms/wwwroot/;#尤其注意這一行,配置靜態檔案目錄
      index /index.html;
  }

  #location ~ /.well-known/acme-challenge {
  #      allow all;
  #  }

  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;

  }
}

7.重啟 Nginx

 /usr/local/nginx/sbin/nginx -s reload