joken-前端工程师

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

===首先到gogs文件的scripts里面找到启动文件

cd /home/gogs/gogs/scripts/init/centos

 

==然后拷贝到/etc/init.d

mv ./gogs /etc/init.d/gogs

 

上面的gogs是启动文件。 内容如下:

#!/bin/sh
#
#       /etc/rc.d/init.d/gogs
#
#       Runs the Gogs
#       
#
# chkconfig:   - 85 15 
#

### BEGIN INIT INFO
# Provides:          gogs
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      mysql postgresql
# Should-Stop:       mysql postgresql
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start gogs at boot time.
# Description:       Control gogs.
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# Default values

NAME=gogs
GOGS_HOME=/home/git/gogs
GOGS_PATH=${GOGS_HOME}/$NAME
GOGS_USER=git
SERVICENAME="Gogs"
LOCKFILE=/var/lock/subsys/gogs
LOGPATH=${GOGS_HOME}/log
LOGFILE=${LOGPATH}/gogs.log
RETVAL=0

# Read configuration from /etc/sysconfig/gogs to override defaults
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME

# Don't do anything if nothing is installed
[ -x ${GOGS_PATH} ] || exit 0
# exit if logpath dir is not created.
[ -x ${LOGPATH} ] || exit 0

DAEMON_OPTS="--check $NAME"

# Set additional options, if any
[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"

start() {
  cd ${GOGS_HOME}
  echo -n "Starting ${SERVICENAME}: "
  daemon $DAEMON_OPTS "${GOGS_PATH} web > ${LOGFILE} 2>&1 &"
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch ${LOCKFILE}
        
  return $RETVAL
}

stop() {
  cd ${GOGS_HOME}
        echo -n "Shutting down ${SERVICENAME}: "
        killproc ${NAME}
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f ${LOCKFILE} 
}

case "$1" in
    start)
        status ${NAME} > /dev/null 2>&1 && exit 0
        start
        ;;
    stop)
        stop
        ;;
    status)
        status ${NAME}
        ;;
    restart)
        stop
        start
        ;;
    reload)
        stop
        start
        ;;
    *)
        echo "Usage: ${NAME} {start|stop|status|restart}"
        exit 1
        ;;
esac
exit $RETVAL

 

===修改gogs启动文件里gogs的安装地址:

GOGS_HOME=/home/git/gogs

 

===提交执行权限

chmod +x /etc/init.d/gogs

 

===最后添加到开机启动

 

vi /etc/rc.local

#添加启动

/etc/init.d/gogs start

 

posted on 2018-06-07 21:37  joken1310  阅读(1814)  评论(0编辑  收藏  举报