运维需求:获取服务器的运行情况,是否CPU、内存较高等,上报到运维系统

环境:ubuntu16.04

工具::netcore2.1、supervisor

程序实现(代码就不贴了)参考:https://blog.csdn.net/u014518337/article/details/86291984

因需要获取系统数据,部分命令行不支持在docker环境运行,因此直接由dotnet直接运行程序,守护进程由supervisor 守护

1、安装netcore2.1

wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1

执行 dotnet --info  查看是否安装正确

2、安装supervisor

参考:https://www.cnblogs.com/savorboard/p/dotnetcore-supervisor.html

sudo apt-get install supervisor

安装完成之后,在 /ect/supervisor/conf.d/ 目录下新建一个配置文件(touch HelloWebApp.conf),取名为 HelloWebApp.conf

打开HelloWebApp.conf (vim HelloWebApp.conf),写入如下命令:

[program:HelloWebApp]
command=dotnet HelloWebApp.dll #要执行的命令
directory=/home/xxx/publish #命令执行的目录
environment=ASPNETCORE__ENVIRONMENT=Production #环境变量
user=www-data #进程执行的用户身份
stopsignal=INT
autostart=true #是否自动启动
autorestart=true #是否自动重启
startsecs= #自动重启间隔
stderr_logfile=/var/log/HelloWebApp.err.log #标准错误日志
stdout_logfile=/var/log/HelloWebApp.out.log #标准输出日志

注意:上面代码需要把注释 #后面的中文删掉

修改配置文件/etc/supervisor/supervisord.conf  添加supervisord web管理功能  红色为新增配置部分

;upervisor config file

[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod= ; sockef file mode (default ) [inet_http_server]
port=*:9001
username=user
password=123 [supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) ; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [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 are
; interpreted as relative to this file. Included files *cannot*
; include files themselves. [include]
files = /etc/supervisor/conf.d/*.conf

保存之后重启下程序

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

如果启动异常根据提示查看配置修改配置文件

netcore应用程序部署程序到ubuntu的更多相关文章

  1. netcore程序部署 ubuntu 16.0.4 报错 The type initializer for 'System.Net.Http.CurlHandler'的解决方案

    最近业务扩展需要把netcore程序部署到ubuntu 16.0.4上,因为代码里面用到了HttpClient 请求. 部署ubuntu后一直报错 参考地址:https://github.com/do ...

  2. netcore程序部署及守护

    一.程序发布 1.在本机编译无误的情况下,选择发布成文件系统.注意如果使用了swagger 需要将生成的xml文档说明复制到发版包里面.否则会报错.(可以在项目的csproj 中加入 <Prop ...

  3. 使用VS Code 开发.NET Core 应用程序 部署到Linux 跨平台

    使用VS Code 开发.NET Core 应用程序 部署到Linux 跨平台. 前面讲解了VSCode开发调试 .NET Core.都只是在windows下运行. .NET Core真正的核心是跨平 ...

  4. .net程序部署(mono方式)

    某一次 我同事用了这个词 ,说这样才显得够专业 擦.把某某项目 部署到服务器上 .擦 不就是拷个文件过去运行么.月亮 还是绵羊  我搞不清楚了 咱英文不好,绵羊叫的声音?.你就叫我山寨程序猿 随意 一 ...

  5. deployment与Web应用程序部署

    定义用于支持 Web 应用程序部署的配置设置. <deployment retail="true|false" /> retail属性:设置一个值,该值指定是否以发布模 ...

  6. IIS安装与MVC程序部署

    最近在做访客系统,虽然说不是什么多大的项目,但麻雀虽小五脏俱全,使用EF Code First+Mysql+Frozenui响应式布局,感觉通过这个项目学到好多东西,Mysql的使用.EF映射Mysq ...

  7. SNF开发平台WinForm之八-自动升级程序部署使用说明-SNF快速开发平台3.3-Spring.Net.Framework

    9.1运行效果: 9.2开发实现: 1.首先配置服务器端,把“SNFAutoUpdate2.0\服务器端部署“目录按网站程序进行发布到IIS服务器上. 2.粘贴语句,生成程序 需要调用的应用程序的Lo ...

  8. 新手在sae部署程序容易忽略的一个细节

    从来没用过这类云空间服务,尝了下鲜试用一下sae,但是部署的时候发现问题了,各种404..各种无奈啊..虽然百度无数篇介绍,但是都千篇一律没什么启发.. 但是巧在我部署的应用有个欢迎页面,点击链接的时 ...

  9. [翻译][MVC 5 + EF 6] 5:Code First数据库迁移与程序部署

    原文:Code First Migrations and Deployment with the Entity Framework in an ASP.NET MVC Application 1.启用 ...

随机推荐

  1. 获取spring的IOC核心容器,并根据id获取对象

    public class Client { /** * 获取spring的IOC核心容器,并根据id获取对象 * ApplicationContext的三个常用实现类 * classPathXmlAp ...

  2. Java 多线程 - 生产者消费者问题

    https://www.cnblogs.com/hckblogs/p/7858545.html

  3. 【译】索引进阶(八):SQL SERVER唯一索引

    [译注:此文为翻译,由于本人水平所限,疏漏在所难免,欢迎探讨指正] 原文链接:传送门. 在本章节我们检查唯一索引.唯一索引的特别之处在于它不仅提供了性能益处,而且提供了数据完整性益处.在SQL SER ...

  4. 文件比较与同步工具——FreeFileSync

    1. 基本介绍 FreeFileSync是一个用于文件同步的免费开源程序.FreeFileSync通过比较其内容,日期或文件大小上的一个或多个文件夹,然后根据用户定义的设置同步内容.除了支持本地文件系 ...

  5. 西瓜视频蓝光1080P下载方法

    西瓜视频的蓝光画质只能在APP上看,如何获取1080P画质的地址呢? 1.先安装 WinPcap 2.然后安装夜神安卓模拟器NOX 3.NOX模拟器里安装西瓜视频的最新APP,旧版本APP只提供超清模 ...

  6. 011_TCP专项研究监控

    (1)In Segs 数据源: /proc/net/snmp; 采集方式:累计值,每10秒采集一次取差值: 指标:net.snmp.tcp (key: system); In Segs: tcp协议层 ...

  7. centos命令安装

    1.解决ifconfig命令失效:需要安装net-tools工具 yum install net-tools 2.免密码登录 (1)通过命令,产生公钥信息 ssh-keygen -t rsa 如果提示 ...

  8. pads layout 自动打地孔

    对于PCBLayout来说,后期处理也是一项费时操作,比如为了让板子耦合的更好,会在板子空旷位置打上很多地过孔.“自动打地孔”则会让你省时又省心,一不小心就提前了工期哦,哈哈! 一.下面打开一个简单的 ...

  9. js &运算符什么意思,什么用处

    “&&”连接两个表达式,当两侧表达式都为真时,返回TRUE.有一个为假则返回FALSE. 也就是说,符号前面的如果为true,就会执行符号后面的语句,如果符号前面的为false,那么后 ...

  10. SpringBoot的@Enable*注解的使用介绍

    @EnableAsync或@EnableConfigurationProperties背后的运行原理,是使用了@Import注解. @Import({User.class,Role.class,MyC ...