supervisor 配置程序挂起自启动
使用 supervisor 服务,将程序监控起来,如果程序挂掉了,可以实现自启动
编写 c++ 程序 test.c
#include <stdio.h>
#include <string.h> int main(){
FILE *fp = fopen("./1.txt","a+");
if(fp==){
printf("can't open file\n");
return ;
} int ix = ;
for(;;ix++){
fseek(fp,,SEEK_END);
char s_add_arr[];
memset(s_add_arr,'\0',);
sprintf(s_add_arr,"%i\n",ix);
fwrite(s_add_arr,strlen(s_add_arr),,fp); sleep();
}
fclose(fp);
return ;
}
启动服务
supervisord -c /etc/supervisord.conf
# 使用了默认的配置文件 在 /etc/ 下
要给需要自拉起的程序添加配置文件 默认放在 /etc/supervisor.d/ 目录下,以 .conf 文件结尾
测试程序为 test.conf
[program:test]
command=/home/jingchanglin/code/test/test
autostart=true
autorestart=true
startsecs=
priority=
redirect_stderr=true
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=
stdout_logfile=/home/jingchanglin/code/test/app.log
服务启动后,可以使用 supervisorctl 命令来进入控制台
[root@localhost]# supervisorctl
sshd RUNNING pid , uptime ::
test RUNNING pid , uptime ::
supervisor> help default commands (type help <topic>):
=====================================
add exit open reload restart start tail
avail fg pid remove shutdown status update
clear maintail quit reread signal stop version supervisor>
进入之后,看到的是在监控的程序的名称
使用 help 可以看服务支持哪些自命令
一般常用的包括
reload
重新加载,这样某个新添/删除的服务就可以看到了
shutdown 关闭某个程序
start 启动某个程序
supervisor 配置程序挂起自启动的更多相关文章
- 【netcore基础】ubuntu 16.04 搭建.net core 2.1 linux 运行环境 nginx反向代理 supervisor配置自启动
今天来整理下 netcore 在 linux(ubuntu) 上的运行环境搭建 对应版本 ubuntu 16.04 .net core 2.1 nginx version: nginx/1.10.3 ...
- 【netcore基础】CentOS 7.6.1810 搭建.net core 2.1 linux 运行环境 nginx反向代理 supervisor配置自启动
之前写过一篇Ubuntu的环境搭建博客,感觉一些配置大同小异,这里重点记录下 nginx 作为静态 angular 项目文件服务器的配置 参考链接 [netcore基础]ubuntu 16.04 搭建 ...
- Robotium调用getActivity()导致程序挂起的方法
1. 问题背景的叙述性说明 需要直接用在工作中没有项目的源代码robotium测试目标android平台launcher,该平台的基础上,当前日期的版本号android 4.4.2.之前我用来验证的可 ...
- 配置程序成为Linux服务
最近写了个程序需要随Linux启动时自动运行起来, 查了一些方法后, 通过配置程序成为系统的服务实现了这个需求, 在此记录一下. 测试程序 #! /bin/sh while [ true ] do e ...
- Supervisor 配置过程
Supervisor 配置过程 (转自https://www.izixia.cn/2016/01/03/supervisor-pei-zhi-guo-cheng/) 1.安装 pip install ...
- centos系统supervisor配置
supervisor用来管理非daemon程序!将自动转换为daemon程序 安装: yum install supervisor 配置: 默认配置文件路径: /etc/supervisord.con ...
- .Net Core实战教程(三):使用Supervisor配置守护进程
安装Supervisor yum install python-setuptools easy_install supervisor 配置Supervisor mkdir /etc/superviso ...
- 正尝试在 OS 载入程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内执行托管代码,这样做会导致应用程序挂起。
出错提示: 正尝试在 OS 载入程序锁内执行托管代码. 不要尝试在 DllMain 或映像初始化函数内执行托管代码,这样做会导致应用程序挂起. 原因分析: .NET2.0中添加了42种非常强大的调试助 ...
- AppDelegate关于应用程序挂起、复原与终止的代理方法
AppDelegate关于应用程序挂起.复原与终止的代理方法: 首次运行: - (BOOL)application:(UIApplication *)application didFinishLaun ...
随机推荐
- Dynamics CRM 日常使用JS整理(三)
一.指定 Partylist 类型字段能 lookup 的实体(以 Appointment 中某个字段为例子): var control = Xrm.Page.getControl("req ...
- Java 集合系列08之 List总结
一.List概述 1. List是一个接口,它继承于Collection接口,代表有序集合 2. ArrayList, LinkedList, Vector, Stack是List的4个实现类. Ar ...
- 题解 P4753 【River Jumping】
这道神奇的模拟题,带一点贪心,其实蛮水的,仔细思考就能ac. 首先我们模拟一下样例2 发现其实答案0 1 2 3也可以,仔细观察题目,我们发现了一句有意思的话:允许输出任意一组答案. 所以就可使用xj ...
- python3 练手实例2 解一元二次方程组
import math def y(): a,b,c=map(float,input('请输入一元二次方程式ax^2+bx+c=0,abc的值,用空格隔开:').split()) d=math.pow ...
- webpack配置less
webpack4.0把webpack.config.js隐藏起来了,需要先暴露出来,在webpack修改配置
- net core appsetting配置
public class BaseController : Controller { protected WLEntity _db; protected ILogger _log; protected ...
- SqlServer查询某数据在某表某列中
create proc spFind_Column_In_DB ( @type int,--类型:为文字类型.为数值类型 @str nvarchar(100)--需要搜索的名字 ) as --创建临时 ...
- 2018-2019-2 20175306实验一《Java开发环境的熟悉》实验报告
2018-2019-2 20175306实验一<Java开发环境的熟悉>实验报告 一.实验内容及步骤 实验一 Java开发环境的熟悉-1 ·建立有自己学号的实验目录. ·通过vim Hel ...
- Moment.js简单使用
1.设置语言环境,如设置中文环境: moment.locale("zh-cn"); 2.当前时间.指定时间: // 假设当前时间为:2018年12月10日 moment(); // ...
- ngx_string()错误分析
#define ngx_string(str) { sizeof(str) - 1, (u_char) str } typedef struct { uint len; u_char* data; } ...