Gogs自启动
作者:andy.zhang | 分类:Linux | 浏览:699 | 日期:2021年08月03日1,安装,这个不用多介绍了,官网上直接下载二进制安装即可。
在安装Gogs之前,首先决定数据库,比如mysq,这个需要先安装
2,启动:
正常启动命令是在安装目录下./gogs web >/dev/null &(放在后台运行)
3,开机启动:
这里吐槽一下官网,上面所标示的只是启动脚本的大部分,不能根据安装
目录来更改。以下修改以本人安装目录/data/gogs为主。以下是启动脚本
a):原脚本:
[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
以上脚本是官网上所示。哪怕是修改了工作路径和启动路径,均不能正常启动服务。
b):修改脚本:
[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=root
Group=root
WorkingDirectory=/data/gogs
ExecStart=/data/gogs/gogs web
#注,上面这里不加&也是在后台运行
Restart=always
#Environment=USER=git HOME=/bin/git
Environment=USER=root HOME=/root
#这里是关键,我原来把上面的路径改了,也运行不了。
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
愿各位以后使用gogs顺利。再次证明,百度对程序员来说是多么的无用。