
官方推荐 gitea.service 内容:
[Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target [Service] RestartSec=2s Type=notify User=git Group=git WorkingDirectory=/var/lib/gitea/ ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini Restart=always EnvirOnment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea WatchdogSec=30s [Install] WantedBy=multi-user.target 执行 systemctl start gitea.service 之后几乎每分钟崩溃一次。日志如下:
5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 cmd/web.go:105:runWeb() [I] Starting Gitea on PID: 846 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:21:PreloadSettings() [I] AppPath: /usr/local/bin/gitea 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:22:PreloadSettings() [I] AppWorkPath: /var/lib/gitea 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:23:PreloadSettings() [I] Custom path: /var/lib/gitea/custom 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:24:PreloadSettings() [I] Log path: /var/lib/gitea/log 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:25:PreloadSettings() [I] Configuration file: /etc/gitea/app.ini 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:26:PreloadSettings() [I] Prepare to run install page 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/install/setting.go:29:PreloadSettings() [I] SQLite3 is supported 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 cmd/web.go:220:listen() [I] [64709e72-6] Listen: http://0.0.0.0:3000 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 cmd/web.go:224:listen() [I] [64709e72-6] AppURL(ROOT_URL): http://localhost:3000/ 5 月 26 19:56:34 computer88 gitea[846]: 2023/05/26 19:56:34 ...s/graceful/server.go:62:NewServer() [I] [64709e72-6] Starting new Web server: tcp:0.0.0.0:3000 on PID: 846 5 月 26 19:58:04 computer88 gitea[846]: 2023/05/26 19:58:04 ...eful/manager_unix.go:149:handleSignals() [W] [64709e72-4] PID 846. Received SIGTERM. Shutting down... 5 月 26 19:58:04 computer88 gitea[846]: 2023/05/26 19:58:04 .../graceful/manager.go:205:doHammerTime() [W] Setting Hammer condition 5 月 26 19:58:04 computer88 gitea[846]: 2023/05/26 19:58:04 cmd/web.go:271:listen() [I] [64709e72-6] HTTP Listener: 0.0.0.0:3000 Closed 5 月 26 19:58:04 computer88 gitea[846]: 2023/05/26 19:58:04 ...eful/server_hooks.go:46:doShutdown() [I] [64709e72-6] PID: 846 Listener ([::]:3000) closed. 5 月 26 19:58:04 computer88 systemd[1]: gitea.service: start operation timed out. Terminating. 5 月 26 19:58:05 computer88 gitea[846]: 2023/05/26 19:58:05 .../graceful/manager.go:224:doTerminate() [W] Terminating 5 月 26 19:58:05 computer88 gitea[846]: 2023/05/26 19:58:05 ...eful/manager_unix.go:157:handleSignals() [W] PID: 846. Background context for manager closed - context canceled - Shutting down... 5 月 26 19:58:05 computer88 gitea[846]: 2023/05/26 19:58:05 cmd/web.go:139:runWeb() [I] PID: 846 Gitea Web Finished 5 月 26 19:58:05 computer88 systemd[1]: gitea.service: Failed with result 'timeout'. 5 月 26 19:58:05 computer88 systemd[1]: Failed to start Gitea (Git with a cup of tea). 5 月 26 19:58:07 computer88 systemd[1]: gitea.service: Scheduled restart job, restart counter is at 1. 5 月 26 19:58:07 computer88 systemd[1]: Stopped Gitea (Git with a cup of tea). 5 月 26 19:58:07 computer88 systemd[1]: Starting Gitea (Git with a cup of tea)... 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 cmd/web.go:105:runWeb() [I] Starting Gitea on PID: 1410 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:21:PreloadSettings() [I] AppPath: /usr/local/bin/gitea 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:22:PreloadSettings() [I] AppWorkPath: /var/lib/gitea 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:23:PreloadSettings() [I] Custom path: /var/lib/gitea/custom 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:24:PreloadSettings() [I] Log path: /var/lib/gitea/log 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:25:PreloadSettings() [I] Configuration file: /etc/gitea/app.ini 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:26:PreloadSettings() [I] Prepare to run install page 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/install/setting.go:29:PreloadSettings() [I] SQLite3 is supported 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 cmd/web.go:220:listen() [I] [64709ecf-6] Listen: http://0.0.0.0:3000 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 cmd/web.go:224:listen() [I] [64709ecf-6] AppURL(ROOT_URL): http://localhost:3000/ 5 月 26 19:58:07 computer88 gitea[1410]: 2023/05/26 19:58:07 ...s/graceful/server.go:62:NewServer() [I] [64709ecf-6] Starting new Web server: tcp:0.0.0.0:3000 on PID: 1410 5 月 26 19:59:37 computer88 systemd[1]: gitea.service: start operation timed out. Terminating. 5 月 26 19:59:37 computer88 gitea[1410]: 2023/05/26 19:59:37 ...eful/manager_unix.go:149:handleSignals() [W] [64709ecf-4] PID 1410. Received SIGTERM. Shutting down... 5 月 26 19:59:37 computer88 gitea[1410]: 2023/05/26 19:59:37 .../graceful/manager.go:205:doHammerTime() [W] Setting Hammer condition 5 月 26 19:59:37 computer88 gitea[1410]: 2023/05/26 19:59:37 cmd/web.go:271:listen() [I] [64709ecf-6] HTTP Listener: 0.0.0.0:3000 Closed 5 月 26 19:59:37 computer88 gitea[1410]: 2023/05/26 19:59:37 ...eful/server_hooks.go:46:doShutdown() [I] [64709ecf-6] PID: 1410 Listener ([::]:3000) closed. 5 月 26 19:59:38 computer88 gitea[1410]: 2023/05/26 19:59:38 .../graceful/manager.go:224:doTerminate() [W] Terminating 5 月 26 19:59:38 computer88 gitea[1410]: 2023/05/26 19:59:38 cmd/web.go:139:runWeb() [I] PID: 1410 Gitea Web Finished 5 月 26 19:59:38 computer88 systemd[1]: gitea.service: Failed with result 'timeout'. 5 月 26 19:59:38 computer88 systemd[1]: Failed to start Gitea (Git with a cup of tea). 将 gitea.service 中的 Type=notify 改成 Type=simple 后,就可以正常启动,并且后台程序不再崩溃。 按理说官方的写法一定是最好的,应该不会给我一个小白都能发现的改动空间。不理解,请大佬答疑解惑,谢谢了。
| div class="fr"> 1 lolizeppelin 2023-05-26 21:09:40 +08:00 装 rpm 版 |
2 lolizeppelin 2023-05-26 21:11:54 +08:00 notify 是因为你配置里没配置 systemd 通知 systemd 认为你进程启动未完成所以到默认通知超时时间后就干掉了你的进程 去配置里找 systemd notify 相关配置 |
3 feedcode 2023-05-26 21:22:27 +08:00 |
4 flyqie 2023-05-26 23:06:23 +08:00 最简单靠谱抄 gitea.service 的办法: 1. 选好你打算安装的版本 2. 去 github 看对应版本 tag 的代码库 3. 拿代码库里的 contrib/systemd/gitea.service 改。 绝对不会出问题。 |
5 lhx888 OP @feedcode @lolizeppelin 谢谢您的回复,有可能这是 ubuntu 使用的版本的原因吧,而我的系统是 debian,把 Type=notify 改成 Type=simple , 再删除 WatchdogSec=30s ,后台就可以稳定运行了。 |