要在CentOS系统上设置开机自动启动EasyDarwin服务

12个月前 (05-12 21:32)阅读7回复0
administrator
administrator
  • 管理员
  • 注册排名1
  • 经验值775
  • 级别管理员
  • 主题155
  • 回复0
楼主
  1. 首先,确保EasyDarwin服务已经安装并配置好了。

  2. 使用root权限登录CentOS系统。

  3. 打开终端,输入以下命令来编辑EasyDarwin服务的启动脚本:

sudo vi /etc/init.d/easydarwin
  1. 在打开的编辑器中,输入以下内容作为EasyDarwin服务的启动脚本:

#!/bin/sh## EasyDarwin: Start/Stop the EasyDarwin daemon.## chkconfig: 345 95 5# description: EasyDarwin is a lightweight and high-performance streaming server#### BEGIN INIT INFO# Provides: EasyDarwin# Required-Start: $network $local_fs $remote_fs# Required-Stop: $network $local_fs $remote_fs# Default-Start: 3 4 5# Default-Stop: 0 1 2 6# Short-Description: start and stop EasyDarwin# Description: EasyDarwin is a lightweight and high-performance streaming server### END INIT INFO# Source function library.. /etc/rc.d/init.d/functions

prog=easydarwin
exec=/usr/local/easydarwin/easydarwin

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    echo -n $"Starting $prog: "
    daemon $exec
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $lockfile
    return $RETVAL
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $lockfile
    return $RETVAL
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $prog
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit $?
  1. 保存并退出编辑器,然后输入以下命令来设置EasyDarwin服务的启动脚本为可执行文件:

sudo chmod +x /etc/init.d/easydarwin
  1. 最后,使用以下命令来设置EasyDarwin服务开机自动启动:

sudo chkconfig easydarwin on

现在,EasyDarwin服务将会在CentOS系统启动时自动启动。您可以使用以下命令来手动启动、停止或查看EasyDarwin服务的状态:

  • 启动:sudo service easydarwin start

  • 停止:sudo service easydarwin stop

  • 查看状态:sudo service easydarwin status


0
回帖

要在CentOS系统上设置开机自动启动EasyDarwin服务 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息