[SOLVED] Unable to start server via systemd

Hi,

I am able to start the gitea server via shell but not via systemd. Starting via systemd fails when creating notification queues.
I am running this on latest OpenSuse Tumbleweed using sqlite3 database.
I double checked the file permissions and “git” user does have access to the Gitea ROOT directory. Any pointers?

SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) AND status = ? GROUP BY user_id [1599766828 1599766838 1] - 156.695µs
2020/09/10 15:40:50 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT user_id, count(*) AS count FROM notification WHERE user_id IN (SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) AND status = ? GROUP BY user_id [1599766838 1599766848 1] - 158.889µs
2020/09/10 15:41:00 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT user_id, count(*) AS count FROM notification WHERE user_id IN (SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) AND status = ? GROUP BY user_id [1599766848 1599766858 1] - 157.747µs
2020/09/10 15:41:10 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT user_id, count(*) AS count FROM notification WHERE user_id IN (SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) AND status = ? GROUP BY user_id [1599766858 1599766868 1] - 174.108µs
2020/09/10 15:41:20 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT user_id, count(*) AS count FROM notification WHERE user_id IN (SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) AND status = ? GROUP BY user_id [1599766868 1599766878 1] - 162.447µs
2020/09/10 15:41:30 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT `id`, `repo_id`, `interval`, `enable_prune`, `updated_unix`, `next_update_unix` FROM `mirror` WHERE (next_update_unix<=?) AND (next_update_unix!=0) [1599766890] - 136.277µs
2020/09/10 15:41:30 ...m.io/xorm/core/db.go:277:ExecContext() [I] [SQL] INSERT INTO `notice` (`type`,`description`,`created_unix`) VALUES (?, ?, ?) [2 Cron: Update Mirrors has finished 1599766890] - 27.966874ms
2020/09/10 15:41:30 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT user_id, count(*) AS count FROM notification WHERE user_id IN (SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) AND status = ? GROUP BY user_id [1599766878 1599766888 1] - 159.611µs
2020/09/10 15:41:37 ...eful/manager_unix.go:121:handleSignals() [W] PID 19500. Received SIGINT. Shutting down...
2020/09/10 15:41:37 ...ueue_disk_channel.go:144:Run() [F] Unable to create internal queue for notification-service Error: Timedout creating queue level with cfg queue.LevelQueueConfiguration{ByteFIFOQueueConfiguration:queue.ByteFIFOQueueConfiguration{WorkerPoolConfiguration:queue.WorkerPoolConfiguration{QueueLength:20, BatchLength:20, BlockTimeout:1000000000, BoostTimeout:300000000000, BoostWorkers:5, MaxWorkers:6}, Workers:1, Name:"notification-service-level"}, DataDir:"/data-1/server/gitea/data/queues/notification-service"} in notification-service

$ sudo journalctl --no-pager -b 0 -u gitea |tail
Sep 11 04:29:44 nas-lan gitea[31535]: 2020/09/11 04:29:44 ...s/setting/setting.go:725:NewContext() [F] Failed to create '/home/git/.ssh': mkdir /home/git: permission denied
Sep 11 04:29:44 nas-lan systemd[1]: gitea.service: Main process exited, code=exited, status=1/FAILURE
Sep 11 04:29:44 nas-lan systemd[1]: gitea.service: Failed with result 'exit-code'.
Sep 11 04:29:47 nas-lan systemd[1]: gitea.service: Scheduled restart job, restart counter is at 13447.
Sep 11 04:29:47 nas-lan systemd[1]: Stopped Gitea (Git with a cup of tea).
Sep 11 04:29:47 nas-lan systemd[1]: Started Gitea (Git with a cup of tea).
Sep 11 04:29:47 nas-lan gitea[31549]: 2020/09/11 04:29:47 cmd/web.go:107:runWeb() [I] Starting Gitea on PID: 31549
Sep 11 04:29:47 nas-lan gitea[31549]: 2020/09/11 04:29:47 ...s/setting/setting.go:725:NewContext() [F] Failed to create '/home/git/.ssh': mkdir /home/git: permission denied
Sep 11 04:29:47 nas-lan systemd[1]: gitea.service: Main process exited, code=exited, status=1/FAILURE
Sep 11 04:29:47 nas-lan systemd[1]: gitea.service: Failed with result 'exit-code'.

After a lot of searching around, I found the issue. The following link helped me:
https://bbs.archlinux.org/viewtopic.php?id=243804

Essentially, for some reason, the HOME environment variable was set in my systemd unit file. That was causing the mess. Now that I changed it to be the same as working directory, service is starting.

I wasted a lot of time because I was searching for the log files for information. Alas, the real logs were not in the /var/log directory where I configured them to be. They were actually printed to console and were only visible via this command :
sudo journalctl -b 0 -u gitea

That is normal for services managed by systemd. Logs are supposed to be in the journal, and not in various directories on the system. Most of the services running on your system have their logs in the systemd journal.