Bboysoul's Blog

首页 公告 RSS

gitea开机启动

December 28, 2017 本文有 354 个字 需要花费 1 分钟阅读

概述

今天搭建gitea环境的时候突然想到,如果gitea可以开机启动那该多好,找了一下,官方文档上就有

操作

首先新建编辑下面这个文件
sudo vim /etc/systemd/system/gitea.service

输入下面配置文件

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
After=mysqld.service
#After=postgresql.service
#After=memcached.service
#After=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
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gitea
ExecStart=/home/git/gitea/gitea web
Restart=always
Environment=USER=git HOME=/home/git/gitea

[Install]
WantedBy=multi-user.target

之后执行
systemctl daemon-reload
sudo systemctl start gitea

如果服务不能启动,你要注意的是下面几点
首先你的gitea放的目录问题,因为使用git用户启动的服务,所以你的gitea所在目录肯定要让git用户有访问权限,所以root目录下是不可以的
之后上面的配置参数你也要按照自己的环境目录来写,不要复制粘贴了,After=mysqld.service表示在mysql服务启动之后再启动gitea服务,所以这个根据你的数据库来选择去掉哪个注释

欢迎关注我的博客www.bboy.app
Have Fun


Tags:

本站总访问量 本站总访客数