net

「物联网」centos部署asp net core web ap

2018-05-08  本文已影响61人  SmartKarren

SDK安装

$ rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
$ yum install libunwind libicu -y
$ yum install dotnet-sdk-2.1.105
#查看安装信息
$ dotnet --info

nginx Web容器配置

server {
    listen 80;
    location / {
        proxy_pass [http://localhost:5000;](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;
    }
}

守护配置

安装配置守护

$ yum install python-setuptools
$ easy_install supervisor
$ mkdir /etc/supervisor
$ mkdir /etc/supervisor/conf.d
$ echo_supervisord_conf > /etc/supervisor/supervisord.conf
$ vi /etc/supervisor/supervisord.conf
#from
;[include]
;files= relateive/directory/*.ini
#to
[include]
files= conf.d/*.conf

配置守护api

$ cd conf.d
$ vi Web.conf
[program:#yourname]
command=dotnet #yourname.dll ; 运行程序的命令
directory=#yourpath ; 命令执行的目录
autorestart=true ; 程序意外退出是否自动重启
stderr_logfile=#path/yourname.err.log ; 错误日志文件
stdout_logfile=#path/yourname.out.log ; 输出日志文件
environment=ASPNETCORE_ENVIRONMENT=Production ; 进程环境变量,生产环境
user=root ; 进程执行的用户身份
stopsignal=INT
#保存退出

启动守护

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

守护开机启动(不确定)

$ vi supervisord.service
###################
# dservice for systemd (CentOS 7.0+)
# by ET-CS ([https://github.com/ET-CS)](https://github.com/ET-CS))
[Unit]
Description=Supervisor daemon

[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
#####################
$ cp supervisord.service /usr/lib/systemd/system/supervisord.service
$ systemctl enable supervisord
上一篇下一篇

猜你喜欢

热点阅读