Supervisor服务开机自启动
要解决的问题
在机器上部署自己编写的服务时候,我们可以使用Supervisor作为进程检活工具,用来自动重启服务。
但是当机器重启后,Supervisor却不能自动重启,那么谁来解决这个问题呢?
答案就是linux的service。
总体思路
编写一个脚本,然后把它放在/etc/init.d这个目录下,再用service + 脚本名字 运行即可。如果是要开机自动启动那就得用chkconfig命令了。
话不多说,上手做吧!
安装方法
增加service配置
[root@hdx9whvy init.d]# vim /etc/init.d/supervisor
内容为
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
#
# chkconfig: - 95 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
# processname: supervisord
# config: /etc/supervisor/supervisord.conf
# pidfile: /var/run/supervisord.pid
#
# source function library
. /etc/rc.d/init.d/functions
RETVAL=0
start() {
echo -n $"Starting supervisord: "
daemon "/usr/bin/supervisord -c /etc/supervisord.conf"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/supervisord
}
stop() {
echo -n $"Stopping supervisord: "
killproc supervisord
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/supervisord
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/supervisord ] && restart
;;
status)
status supervisord
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
exit $RETVAL
设置脚本为可执行
[root@hdx9whvy init.d]# chmod +x /etc/init.d/supervisor
设置服务开机启动
- service这个命令往往是即时生效,不用开关机,但是重启后服务会回到默认状态。
- chkconfig是用于把服务加到开机自动启动列表里,只要启动它,就能自动启动,重启后永久生效
[root@hdx9whvy init.d]# chkconfig supervisor on
启停命令
[root@hdx9whvy init.d]# service supervisor start
Starting supervisord: [ OK ]
[root@hdx9whvy init.d]# service supervisor stop
Stopping supervisord: [ OK ]
[root@hdx9whvy ~]# service supervisor restart
Stopping supervisord: [ OK ]
Starting supervisord: [ OK ]
Supervisor服务开机自启动的更多相关文章
- 如何把一个c语言程序做成windows服务开机自启动
原文:如何把一个c语言程序做成windows服务开机自启动 目前写的程序是一个用c语言实现socket侦听的,那么如何把这个程序做成开机自启动呢? 我们是通过vs6.0,编译后生成了.exe文件,然后 ...
- linux 服务开机自启动systemd方式 (Centos7)
linux 服务开机自启动systemd方式 (Centos7) 1.编写一个 /opt/hello.sh 脚本 [root@jws-ftp prometheus]# cat /opt/hello.s ...
- Linux(centos7)设置docker服务开机自启动以及容器自启动
docker服务开机自启动 systemctl enable docker 设置容器自启动 可以在运行的时候通过设置--restart 参数 docker run --restart always - ...
- Linux服务开机自启动设置
Linux中也有类似于Window中的开机自启动服务,主要是通过chkconfig命令来设置.它主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服 ...
- 用DOS命令配置服务开机自启动
2016-08-19 15:01 Create 使用命令 sc config 参考博客:http://blog.csdn.net/it1988888/article/details/7992626 ...
- 设置redis服务开机自启动
今天周一,一大早来公司开完会,就听到开发的同学说本地项目起不来了,叫我查下原因.想了下,他们本地项目只跟我们公司的一台内网服务器有关,那台服务器他们要用到的呢,也就只有mysql和redis这两个服务 ...
- Linux(Debian) 上安装tomcat并注册服务开机自启动
1.准备工作 a.下载tomcat linux的包,地址:http://tomcat.apache.org/download-80.cgi,我们下载的版本是8.0,下载方式如图: b ...
- Linux服务开机自启动使用示例
本文以redis服务为例,介绍了两种服务自启动的方法service,systemctl使用示例 1.修改redis.conf,允许后台运行 daemonize no 改为 daemonize yes ...
- windows server 2008R2 配置tomcat服务开机自启动
一.配置环境 操作系统:Windows server 2008 R2 软件包:jdk_1.7.rar 二.安装操作 1,右击解压jdk_1.7.rar:解压后双击运行jdk-7u79-windows- ...
随机推荐
- SpringBoot | 3.1 配置数据源
目录 前言 1. 数据源的自动配置 2. *数据源自动配置源码分析 2.1 DataSourceAutoConfiguration:数据源自动配置类 2.2 JdbcTemplateAutoConfi ...
- odoo14里面的用户登录log记录
一.继承userlog,添加字段 # -*- coding: utf-8 -*- from odoo import models, fields, api from odoo.http import ...
- OVERLAPPED 结构
typedef struct _OVERLAPPED { ULONG_PTR Internal; ULONG_PTR InternalHigh; union { struct { DWORD Offs ...
- 构建后端第2篇之---springb @ComponentScan注解使用
张艳涛写于2021-2-8日 构建后端项目的时候遇到一个问题,在zyt-auth项目的依赖定义了@Component类,这个类在项目启动的时候提示没有找到bean Field tokenService ...
- 浅析线程池 ThreadPoolExecutor 源码
首先看下类的继承关系,不多介绍: public interface Executor {void execute(Runnable);} public interface ExecutorServic ...
- JS进度条顺滑版实现
进度条不顺滑 相信大多前端同学都自己写过音频.视频播放器,实现并不复杂.最近在小程序里,做了一个类似微博刷视频的需求.其中有一部分功能需要实现自定义进度条,在做完第一版之后发现进度条不顺滑,而后想查查 ...
- GC相关问题
为什么会有新生代? 如果不分代,所有对象全部在一个区域,每次GC都需要对全堆进行扫描,存在效率问题.分代后,可分别控制回收频率,并采用不同的回收算法,确保GC性能全局最优. 为什么新生代会采用复制算法 ...
- 创建函数,传递一个数字n,返回斐波那契数列的第n的值。
斐波那契数列 第1项和第2项的值是1,从第3项开始,每项的值是前两项相加的和 1 1 2 3 5 8 13 21...... 法1: function fn(n) ...
- CF201C Fragile Bridges TJ
本题解依旧发布于洛谷,如果您能点个赞的话--(逃 前言 题目链接 正解:动态规划 思路不是很好想,想出来了应该就没有多大问题了,但是需要处理的细节较多,再加上水水的样例,难度应该是偏难的.个人感觉应该 ...
- 探讨UE4中的UBT和UHT
前言 UBT和UHT是编译工具,谁定义的呢,虚幻引擎自己定义的,拿来做什么呢,UBT和UHT是UE4用来简化多平台编译,去除用户自定义平台编译项目的操作 我们写的UE4代码不是标准的C++代码,是基于 ...