table of Contents
2. How to use systemd, let's run the program write their own mistakes, can automatically restart
1) in the / lib / systemd / system, create a file below, gogs.service
1. systemd What is that?
Reference: http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
Compared with the traditional systemd init, is the first operating system to start the process, and then start the individual services management of systemd, d refers to the daemon, daemon
Each service, stored in / lib / systemd / system /, the following, sytemctl enable, will create a soft link pointing to this service in the / etc / systemd / system / below
2. How to use systemd, let's run the program write their own mistakes, can automatically restart
1) in the / lib / systemd / system, create a file below, gogs.service
[Unit]
Description=Gogs
After=network.target
[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=forking
User=gogs
Group=gogs
WorkingDirectory=/usr/local/git/gogs
ExecStart=/bin/sh /usr/local/git/gogs/gogs.sh
Restart=always
Environment=USER=gogs HOME=/home/gogs
# 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
————————————————
版权声明:本文为CSDN博主「码农农码一生」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chenhao_c_h/article/details/92064209
2) Operation service
systemctl daemon-reload
systemctl enable gogs.service
systemctl start gogs.service
查看 sercvice 状态
systemctl status gogs.service