Issue running Gitea 1.21.5 via systemctl - user issue

I recently inherited an existing git server, and am trying to update Gitea, but after updating, it won’t start and it seems it be something to do with systemd users.

It is all running on an Ubuntu (18.04.6 LTS) server, for which I use the user “rd” to SSH into from my machine.

Previously, it was running Gitea version 1.15.3 and I have updated it to 1.21.5.

Initially it was throwing some errors due to changes in the expected file structure of the custom directory, but I managed to update everything and get rid of the errors.

The running of Gitea is handled by systemd. So I call “systemctl start gitea” and then “systemctl status gitea” which reports back the following:

rd@rd1:~$ systemctl status gitea
● gitea.service - Gitea
   Loaded: loaded (/home/git/gitea/gitea.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2024-02-27 12:22:06 UTC; 999ms ago
     Docs: https://docs.gitea.io/en-us/
  Process: 19516 ExecStart=/home/git/gitea/gitea web -c /home/git/gitea/custom/conf/app.ini (code=exited, status=1/FAILU
 Main PID: 19516 (code=exited, status=1/FAILURE)

Feb 27 12:22:06 rd1 systemd[1]: gitea.service: Main process exited, code=exited, status=1/FAILURE
Feb 27 12:22:06 rd1 systemd[1]: gitea.service: Failed with result 'exit-code'.

Which doesn’t give much information. So I found somewhere about “gitea doctor” which returns the following:

rd@rd1:~$ /home/git/gitea/gitea doctor
2024/02/27 12:29:55 ...s/setting/setting.go:196:mustCurrentRunUserMatch() [F] Expect user 'git' but current user is: rd

I have done quite a bit of searching and have tried many things, and the key things that I have checked are:

  • RUN_USER in /home/git/gitea/custom/conf/app.ini is set to “git”
  • “Environment” in gitea.service has “USER=git” under /etc/systemd/system/
  • “git” is a user on the machine

The only thing I could find is that in the code the line it fails on (setting.go) mentions something about SSH config. The server is configured as follows (redacted IP addresses) in /home/git/gitea/custom/conf/app.ini:

[server]
SSH_DOMAIN = X.X.X.X
DOMAIN = X.X.X.X
HTTP_PORT = 3000
ROOT_URL = http://rd1/
DISABLE_SSH = false
SSH_PORT = 2222
LFS_START_SERVER = true
LFS_JWT_SECRET = ls-q0T4QeIUwhD9zOiv2aSpnX2y12LjyTgI-GDWmVNg
OFFLINE_MODE = false

Any pointers to what the issue might be?

EDIT:

Realised that the error I was getting from doctor was because running gitea doctor was trying to run it as user rd. Forcing it to run as user git by sudo -H -u git bash -c './gitea doctor check' gives the following output:

rd@rd1:/home/git/gitea$ sudo -H -u git bash -c './gitea doctor check'
[sudo] password for rd:

[1] Check paths and basic configuration
 - [I] Configuration File Path:    "/home/git/gitea/custom/conf/app.ini"
 - [I] Repository Root Path:       "/home/git/gitea-repositories"
 - [I] Data Root Path:             "/home/git/gitea/data"
 - [I] Custom File Root Path:      "/home/git/gitea/custom"
 - [I] Work directory:             "/home/git/gitea"
 - [I] Log Root Path:              "/home/git/gitea/log"
OK

[2] Check Database Version
 - [I] Expected database version: 280
OK

[3] Check if user with wrong type exist
OK

[4] Check if OpenSSH authorized_keys file is up-to-date
OK

[5] Synchronize repo HEADs
 - [I] All 183 repos have their HEADs in the correct state
OK

All done (checks: 5).

Which all looks happy.

I have tried running journalctl -b 0 -u gitea to try and get more information about why systemctl is exiting, but don’t get anything helpful:

Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:242:runWeb() [I] Starting Gitea on PID: 31130
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.21.5 built with GNU Make 4.3, go1.21.6 : bindata, sqlite, sqlite_unlock_no
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: /home/git/gitea/gitea
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: /home/git/gitea
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: /home/git/gitea/custom
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: /home/git/gitea/custom/conf/app.ini
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run web server
Feb 27 13:34:50 rd1 gitea[31130]: 2024/02/27 13:34:50 routers/init.go:112:InitWebInstalled() [I] Git version: 2.17.1 (home: /home/git/gitea/data/home)
Feb 27 13:34:51 rd1 systemd[1]: gitea.service: Main process exited, code=exited, status=1/FAILURE
Feb 27 13:34:51 rd1 systemd[1]: gitea.service: Failed with result 'exit-code'.

UPDATE: fixed this issue. Was a bit of tail chasing. Turned out that it was just custom HTML code in custom/templates/base/footer_content.tmpl that was causing all the issues.

1 Like