Linux 部署 gitea。无法用 service 启动

172 天前
 helee9199

./gitea web 可以启动 但是想设置为 service 启动就失败 /etc/systemd/system/gitea.service 配置

[Unit]
Description=Gitea
After=syslog.target
After=network.target

[Service]
RestartSec=2s
Type=simple
User=git
Group=git
ExecStart=/usr/local/gitea web --config /usr/local/gitea/custom/conf/app.ini
Restart=always

[Install]
WantedBy=multi-user.target

权限也给了

[root@localhost local]# ls -l /usr/local/gitea
total 131008
drwxrwxr-x.  3 git git        18 Nov 18 06:21 custom
drwxrwxr-x. 15 git git       213 Nov 18 07:30 data
-rwxr-xr-x.  1 git git 134150560 Oct  3 21:27 gitea
drwxrwxr-x.  2 git git         6 Nov 18 06:10 log
[root@localhost local]# ls -l /usr/local/gitea/custom/conf/app.ini
-rw-r--r--. 1 git git 1602 Nov 18 06:21 /usr/local/gitea/custom/conf/app.ini
[root@localhost local]# sudo chown git:git /usr/local/gitea
[root@localhost local]# sudo chmod 755 /usr/local/gitea
[root@localhost local]# sudo systemctl start gitea
[root@localhost local]# systemctl status gitea
● gitea.service - Gitea
   Loaded: loaded (/etc/systemd/system/gitea.service; disabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2023-11-18 17:59:04 CST; 1s ago
  Process: 2945 ExecStart=/usr/local/gitea web --config /usr/local/gitea/custom/conf/app.ini (code=exited, status=203/EXEC)
 Main PID: 2945 (code=exited, status=203/EXEC)

Nov 18 17:59:04 localhost.localdomain systemd[1]: gitea.service: main process exited, code=exited, status=203/EXEC
Nov 18 17:59:04 localhost.localdomain systemd[1]: Unit gitea.service entered failed state.
Nov 18 17:59:04 localhost.localdomain systemd[1]: gitea.service failed.

就是启动不起来 是什么原因

3323 次点击
所在节点    Linux
30 条回复
kaneg
172 天前
换 docker 版本省事
helee9199
172 天前
@kaneg 折腾半天了 就差临门一脚了 XD... 不甘心啊。总得弄明白
cxzlhr
172 天前
他需要配置一个 home 目录,默认路径在这这里,/var/lib/gitea/,如果想修改也可以在 service 里面这样改

Environment=USER=git HOME=/data/gitea_home GITEA_WORK_DIR=/data/gitea


```
ls -al /var/lib/gitea/
drwxr-xr-x 3 git git 18 Nov 17 07:14 .
drwxr-xr-x. 41 root root 4096 Nov 17 07:14 ..
drwx------ 2 git git 73 Nov 17 07:43 .ssh
```
yaott2020
172 天前
去看文档,文档有示例
adoal
172 天前
没有正规运维经验就老老实实按照文档做,不要自己发挥
Quarter
172 天前
看一下具体报了什么错
helee9199
172 天前
@cxzlhr 这段配置我在官方配置看到了。
我也有尝试配置成 Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/usr/local/gitea
HOME 和 GITEA_WORK_DIR 的位置我是问的 gpt
不知道是没配对还是什么原因 也是没启动成功
ferock
172 天前
docker 多安稳
helee9199
172 天前
@Quarter journalctl -u gitea
```xml
-- Logs begin at Sat 2023-11-18 18:13:46 CST, end at Sat 2023-11-18 18:43:38 CST. --
Nov 18 18:16:53 localhost.localdomain systemd[1]: Starting Gitea (Git with a cup of tea)...
Nov 18 18:16:53 localhost.localdomain systemd[1]: gitea.service: main process exited, code=exited, status=203/EXEC
Nov 18 18:16:53 localhost.localdomain systemd[1]: Failed to start Gitea (Git with a cup of tea).
Nov 18 18:16:53 localhost.localdomain systemd[1]: Unit gitea.service entered failed state.
Nov 18 18:16:53 localhost.localdomain systemd[1]: gitea.service failed.
Nov 18 18:16:55 localhost.localdomain systemd[1]: gitea.service holdoff time over, scheduling restart.
Nov 18 18:16:55 localhost.localdomain systemd[1]: Stopped Gitea (Git with a cup of tea).
Nov 18 18:16:55 localhost.localdomain systemd[1]: Starting Gitea (Git with a cup of tea)...
Nov 18 18:16:55 localhost.localdomain systemd[1]: gitea.service: main process exited, code=exited, status=203/EXEC
Nov 18 18:16:55 localhost.localdomain systemd[1]: Failed to start Gitea (Git with a cup of tea).
Nov 18 18:16:55 localhost.localdomain systemd[1]: Unit gitea.service entered failed state.
Nov 18 18:16:55 localhost.localdomain systemd[1]: gitea.service failed.
Nov 18 18:16:57 localhost.localdomain systemd[1]: gitea.service holdoff time over, scheduling restart.
Nov 18 18:16:57 localhost.localdomain systemd[1]: Stopped Gitea (Git with a cup of tea).
Nov 18 18:16:57 localhost.localdomain systemd[1]: Starting Gitea (Git with a cup of tea)...
Nov 18 18:16:57 localhost.localdomain systemd[1]: gitea.service: main process exited, code=exited, status=203/EXEC
Nov 18 18:16:57 localhost.localdomain systemd[1]: Failed to start Gitea (Git with a cup of tea).
Nov 18 18:16:57 localhost.localdomain systemd[1]: Unit gitea.service entered failed state.
Nov 18 18:16:57 localhost.localdomain systemd[1]: gitea.service failed.
Nov 18 18:16:59 localhost.localdomain systemd[1]: gitea.service holdoff time over, scheduling restart.
Nov 18 18:16:59 localhost.localdomain systemd[1]: Stopped Gitea (Git with a cup of tea).
```
luojiyin87
172 天前
lng2020
172 天前
这应该和 gitea 没啥关系。你搜一下报错 203 ?
helee9199
172 天前
@lng2020
看起来主要和 ExecStart=/usr/local/gitea web --config /usr/local/gitea/custom/conf/app.ini
这段有关系
问了 gpt 确认文件是否存在,确认是否有权限 这两个都是 OK 的。
to2false
172 天前
systemctl 先 disable ,手动启动 ExecStart 看下详细错误
dzdh
172 天前
我记得有个坑

成功的 code 是 1
加一个 SuccessExitStatus=1 试试
hiveex
172 天前
同建议 docker 一步到位
lng2020
172 天前
app.ini 里是什么东西
dfdragon
172 天前
```
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
After=mysql.service

[Service]
RestartSec=2s
Type=notify
User=git
Group=git
WorkingDirectory=/usr/local/bin/gitea/
ExecStart=/usr/local/bin/gitea/gitea web --config /usr/local/bin/gitea/custom/conf/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/usr/local/bin/gitea
WatchdogSec=30s

[Install]
WantedBy=multi-user.target
```

贴一下我自己的配置,供参考
lng2020
172 天前
你直接去 gitea 官方 QQ 群问好了,这里回复太费事
lng2020
172 天前
type=simple 可能有问题,可以像楼上换成 notify 试试。之前有个工单就是 snap 包安装一直 notify 不到导致 gitea 一直重启。
darrh00
172 天前
看一下 app.ini 里配置日志记录到哪里了,比如

[log]
MODE = file
LEVEL = Info
ROOT_PATH = /home/gitea/log

这样就去 /home/gitea/log/gitea.log 看看有什么日志

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/992990

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX