search

Home  >  Q&A  >  body text

git - How to configure auto-start after gogs installation is complete

After gogs is installed, manually go to /usr/local/src/gogs/ and directly execute ./gogs web to start gogs

But I found a lot of methods on the Internet about gogs configuration auto-start, but none of them work. My environment is centos7

  1. One way is:

    创建文件名/lib/systemd/system/gogs.service
    
    内容
    [Unit]  
    Description=gogs  
    After=network.target  
      
    [Service]  
    Type=forking  
    ExecStart=/usr/local/src/gogs/scripts/init/centos/gogs start  
    ExecReload=/usr/local/src/gogs/scripts/init/centos/gogs restart  
    ExecStop=/usr/local/src/gogs/scripts/init/centos/gogs  stop  
    PrivateTmp=true  
    
    [Install]  
    WantedBy=multi-user.target
    

But it can’t be started

2. In addition:

把/usr/local/src/gogs/scripts/init/centos/gogs拷贝到/etc/init.d/,并且增加x权限

But neither of them can be started using systemctl start gogs.service

天蓬老师天蓬老师2839 days ago1485

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-02 09:51:17

    Please refer to the following service to rewrite it, and then systemctl enable gogs.service

    [Unit]
    Description=Gogs
    After=syslog.target
    After=network.target
    # 数据库,需要的就取消注释吧
    #After=mysqld.service
    #After=postgresql.service
    #After=memcached.service
    #After=redis.service
    
    [Service]
    # 修改工作目录「WorkingDirectory」和启动命令「ExecStart」
    # 如果不需要使用git用户和git用户组来启动的话就把User和Group注释掉,注意Environment也对应要修改
    ###
    Type=simple
    User=git
    Group=git
    WorkingDirectory=/home/git/gogs
    ExecStart=/home/git/gogs/gogs web
    Restart=always
    Environment=USER=git HOME=/home/git
    
    [Install]
    WantedBy=multi-user.target

    reply
    0
  • Cancelreply