配置metersphere开机自启

配置metersphere开机自启

目的:由于在实际测试中,可能经常会出现断电等原因导致服务器异常,那么当服务器恢复时,我们希望第一时间恢复测试环境,而有时可能维护人员并不在公司或者正在处理其他事时,开机自动启动服务就显得非常重要。

1.设置开机自启动docker服务

	systemctl enable docker
	![](https://img-blog.csdnimg.cn/3a31ee54e96b479f90cc1f1dcb84ccf4.png#pic_center)

2.进入路径/etc/init.d/ ,创建文件metersphere(赋予权限777,很重要,如果没有执行权限,开机不会执行)

	cd /etc/init.d
	vi metersphere
	![](https://img-blog.csdnimg.cn/c0314afcfd054604acce57e8c478b77b.png#pic_center)
	
	编辑文件内容:
	注意脚本的第二行与第三行是需要加上的
	其中第二行 chkconfig: 2345 10 90 的含义为:
	2345是默认启动级别 , 10是启动优先级,90是停止优先级,优先级范围是0-100,数字越大,优先级越低
#!/bin/bash
# chkconfig: 2345 10 90
# description: MeterSphere service auto start
function startMeterSphere
{
msctl reload
}
function stopMeterSphere
{
msctl stop
}
function restartMeterSphere
{
stopMeterSphere
startMeterSphere
}
function statusMeterSphere
{
msctl status
}
export HOSTNAME=$HOSTNAME
case "$1" in
start)
startMeterSphere
;;
stop)
stopMeterSphere
;;
restart)
restartMeterSphere
;;
status)
statusMeterSphere
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac

3.将服务添加至自启动列表

	将metersphere服务加到chkconifg列表:
	#自启动打开
	chkconfig metersphere on
	#自启动关闭
	# chkconfig metersphere off

	执行成功后,查看metersphere服务是否加入自启动列表
	chkconifg --list
	![](https://img-blog.csdnimg.cn/a7b4815c8d9b4a5ea0218d1dec9355e7.png#pic_center)
	如果metersphere出现在列表中说明添加成功

4.验证
	执行reboot重启服务器,等待一分钟,发现metersphere自启动已经生效
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值