./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.
就是启动不起来 是什么原因
1
kaneg 2023-11-18 10:08:12 +08:00 via iPhone
换 docker 版本省事
|
3
cxzlhr 2023-11-18 10:18:33 +08:00
他需要配置一个 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 ``` |
4
yaott2020 2023-11-18 10:24:17 +08:00 via Android
去看文档,文档有示例
|
5
adoal 2023-11-18 10:29:17 +08:00
没有正规运维经验就老老实实按照文档做,不要自己发挥
|
6
Quarter 2023-11-18 10:36:00 +08:00 via Android
看一下具体报了什么错
|
7
helee9199 OP @cxzlhr 这段配置我在官方配置看到了。
我也有尝试配置成 Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/usr/local/gitea HOME 和 GITEA_WORK_DIR 的位置我是问的 gpt 不知道是没配对还是什么原因 也是没启动成功 |
8
ferock 2023-11-18 10:44:18 +08:00 via iPhone
docker 多安稳
|
9
helee9199 OP @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). ``` |
10
luojiyin87 2023-11-18 10:45:59 +08:00
|
11
lng2020 2023-11-18 10:51:08 +08:00 via Android
这应该和 gitea 没啥关系。你搜一下报错 203 ?
|
12
helee9199 OP @lng2020
看起来主要和 ExecStart=/usr/local/gitea web --config /usr/local/gitea/custom/conf/app.ini 这段有关系 问了 gpt 确认文件是否存在,确认是否有权限 这两个都是 OK 的。 |
13
to2false 2023-11-18 11:06:01 +08:00
systemctl 先 disable ,手动启动 ExecStart 看下详细错误
|
14
dzdh 2023-11-18 11:12:27 +08:00
我记得有个坑
成功的 code 是 1 加一个 SuccessExitStatus=1 试试 |
15
hiveex 2023-11-18 11:19:50 +08:00
同建议 docker 一步到位
|
16
lng2020 2023-11-18 11:23:29 +08:00 via Android
app.ini 里是什么东西
|
17
dfdragon 2023-11-18 11:31:07 +08:00
```
[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 ``` 贴一下我自己的配置,供参考 |
18
lng2020 2023-11-18 11:32:31 +08:00 via Android
你直接去 gitea 官方 QQ 群问好了,这里回复太费事
|
19
lng2020 2023-11-18 11:34:55 +08:00 via Android
type=simple 可能有问题,可以像楼上换成 notify 试试。之前有个工单就是 snap 包安装一直 notify 不到导致 gitea 一直重启。
|
20
darrh00 2023-11-18 12:01:19 +08:00
看一下 app.ini 里配置日志记录到哪里了,比如
[log] MODE = file LEVEL = Info ROOT_PATH = /home/gitea/log 这样就去 /home/gitea/log/gitea.log 看看有什么日志 |
21
roundgis 2023-11-18 12:08:27 +08:00 via Android
去 gitea 的官方討論區問更快
你先用命令行啟動成功再換成 systemd 也不遲 |
22
guanzhangzhang 2023-11-18 12:24:13 +08:00
|
23
joyanhui 2023-11-18 12:30:04 +08:00 1
su git
/usr/local/gitea web --config /usr/local/gitea/custom/conf/app.ini 先看看 |
24
joyanhui 2023-11-18 12:34:08 +08:00
另外 记得用户名 不是 gitea 吗。。不过我这里是 lxc alpine
```sh ls -lh /var/lib/gitea total 201M -rw------- 1 gitea www-data 1.7K Nov 13 18:48 app.ini drwxr-x--- 2 gitea www-data 4.0K Mar 1 2023 custom drwxr-x--- 14 gitea www-data 4.0K Mar 1 2023 data drwxr-x--- 2 gitea www-data 4.0K Nov 18 12:28 db drwxr-x--- 3 gitea www-data 4.0K Mar 1 2023 git /etc/passwd |grep gitea gitea:x:100:82:gitea:/var/lib/gitea:/bin/ash ``` |
27
lazyyz 2023-11-18 13:03:28 +08:00 via Android
我用的官方示例里的 service 代码,正常可以跑起来
|
28
helee9199 OP @joyanhui 破案了。原来这条是可以执行的,我才发现是这里的问题/usr/local/gitea web
/usr/local/gitea 是安装的文件夹 应该是/usr/local/gitea/gitea web 太淦了。。。 |
29
julyclyde 2023-11-18 13:21:35 +08:00
@guanzhangzhang 主要是吧正常情况下 systemd 里运行出错都是人的错误而非 systemd 的错误
|