/etc/systemd/system/gitea.service 按照官方配置,无法启动。将其中 sype=notify 改成 type=simple 就可以启动

查看 19|回复 0
作者:lhx888   
官方推荐 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 后,就可以正常启动,并且后台程序不再崩溃。
按理说官方的写法一定是最好的,应该不会给我一个小白都能发现的改动空间。不理解,请大佬答疑解惑,谢谢了。
您需要登录后才可以回帖 登录 | 立即注册

返回顶部