Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitea.service systemd script doesn't work on Ubuntu #27422

Closed
TheFriendlyCoder opened this issue Oct 4, 2023 · 7 comments
Closed

gitea.service systemd script doesn't work on Ubuntu #27422

TheFriendlyCoder opened this issue Oct 4, 2023 · 7 comments
Labels

Comments

@TheFriendlyCoder
Copy link

Description

According to the docs one should be able to install Gitea on Ubuntu using snap and then launch the app via a systemd service using the sample service file found here, however based on my recent test deployment on Ubuntu 22.04 this does not work.

After spending some time debugging the problem, it seems the issue comes down to the Type=notify setting in the config file. Based on what I'm seeing, this setting is expecting the Gitea app to send a signal to systemd to notify it when the service is running, but this never actually happens, so systemd assumes the service is hung and times out after a while. Except, after the systemctl start gitea operation fails, the service itself is actually running fine.

Further, in order to side-step this problem in my environment I've simply changes the Type property to Type=simple, which allows the application to launch in the background, so that systemd isn't left waiting for a response from gitea. This is less than ideal because errors in the gitea startup sequence can go unnoticed, but at least it allows the service to start in a best-case scenario.

Gitea Version

Gitea version 1.20.5 built with GNU Make 4.3, go1.21.1 : bindata, sqlite, sqlite_unlock_notify, pam, cert

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

git version 2.34.1

Operating System

Ubuntu 22.04.3 LTS

How are you running Gitea?

As a systemd service.

Database

SQLite

@lunny
Copy link
Member

lunny commented Oct 4, 2023

Maybe #21151 has some problems.

@TheFriendlyCoder
Copy link
Author

Based on this comment I believe you are correct.

@lng2020
Copy link
Member

lng2020 commented Oct 4, 2023

image

works for me in Gitea's latest codebase and Ubuntu22.04. Probably there are some configs in app.ini that should be synced. I just reused my own app.ini in /home/lng2020/gitea and it works well.
my gitea.service file

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
RestartSec=2s
Type=notify
User=lng2020
WorkingDirectory=/home/lng2020/gitea/
ExecStart=/home/lng2020/gitea/gitea web --config /home/lng2020/gitea/custom/conf/app.ini
Restart=always
Environment=USER=lng2020 HOME=/home/lng2020 GITEA_WORK_DIR=/home/lng2020/gitea
WatchdogSec=30s
[Install]
WantedBy=multi-user.target

@lng2020
Copy link
Member

lng2020 commented Oct 4, 2023

After switching to the latest/stable(1.21.5) snap package, the Gitea indeed kept rebooting. The gitea.service file

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
RestartSec=2s
Type=notify
WorkingDirectory=/var/snap/gitea/common
ExecStart=/snap/bin/gitea web --config /var/snap/gitea/common/conf/app.ini
Restart=always
Environment=GITEA_WORK_DIR=/var/snap/gitea/common
WatchdogSec=30s
[Install]
WantedBy=multi-user.target

@techknowlogick
Copy link
Member

I believe snap has its own built-in service manager, snap run gitea or snap start gitea (can't remember which right now) will start the daemon.

@TheFriendlyCoder
Copy link
Author

That being the case, perhaps this is as simple as updating the docs to reflect that.

NOTE: I have confirmed that if I install the latest Gitea binary directly without using snap, the service will run as expected. So it is either a bug with the 1.20.4 version or a limitation of the snap package.

lunny pushed a commit that referenced this issue Oct 5, 2023
Fix the title size and add notes to the Gitea snap package.
Related issue #27424, #27423, #27422, #27420
@techknowlogick
Copy link
Member

Thanks for the suggestion @TheFriendlyCoder. @lng2020 sent a PR to the docs to update them. I'll close this now :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants