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- ...
随机推荐
- MySQL 8.x 新版本特性赶紧学!!Linux 服务器上安装 MySQL 8.x
我是陈皮,一个在互联网 Coding 的 ITer,微信搜索「陈皮的JavaLib」第一时间阅读最新文章,回复[资料],即可获得我精心整理的技术资料,电子书籍,一线大厂面试资料和优秀简历模板. 引言 ...
- 注解@ConfigurationProperties使用方法(二十)
前言 最近在思考使用java config的方式进行配置,java config是指基于java配置的spring.传统的Spring一般都是基本xml配置的,后来spring3.0新增了许多java ...
- Spring自动装配(二)
为什么Spring要支持Autowire(自动装配) 先写几个类,首先定义一个Animal接口表示动物: 1 public interface Animal { 2 3 public void eat ...
- 关于hashcode和equals方法说明
一.前言 我们都知道,要比较两个对象是否相等时需要调用对象的equals()方法,即判断对象引用所指向的对象地址是否相等,对象地址相等时,那么与对象相关的对象句柄.对象头.对象实例数据.对象类型数据等 ...
- IntelliJ IDEA2021.2 常用快捷键汇总总结
Java开发环境:Windows10 64bit+JDK8+IDEA2021.2 =========================================================== ...
- Altium Designer 21.x中文版安装破解教程
Altium Designer 21.x是一款优秀的PCB设计工具,可以原理图设计.电路仿真.PCB绘制编辑.拓扑逻辑自动布线.信号完整性分析和设计输出等功能,为设计者提供了全新的设计解决方案,提高设 ...
- 深入刨析tomcat 之---第4篇 tomcat4.0连接池 实现原理
writedby 张艳涛
- SpringData JPA 使用原生 SQL
在实现个人博客系统的归档功能的时候,遇上这样的需求: 先把数据库中所有条目的时间按照年月分组,并查询出年月(String)的列表 根据年月字符串查询符合条件的博客,并返回博客列表 由于数据访问层使用的 ...
- DC-9靶机
仅供个人娱乐 靶机信息 下载地址:http://www.five86.com/downloads/DC-9.zip 一.主机扫描 二.信息收集 三.漏洞查找和利用 发现search的地方可能有sql注 ...
- sqli-labs 靶场笔记
sqli-labs 靶场笔记 冲冲冲,好好学习 2020年1月12号 先来点铺垫 分类: 按照请求方法分类: 1.Get型注入:注入参数在get的参数里. 2.POST型注入:注入参数在POST的参数 ...