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

updated linux systemd service example and documentation #8109

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions contrib/systemd/gitea.service
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ After=network.target
#LimitNOFILE=65535
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
User=root
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitea should not be run as root.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk averse party poopers...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine. I'll follow the binary install instructions on the actual Gitea site and see if the service works with the gitea.service file.

Group=root
ExecStart=/usr/local/bin/gitea web
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
Environment=USER=root HOME=/root/gitea
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below
###
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
wantedBy=multi-user.target
21 changes: 20 additions & 1 deletion docs/content/doc/installation/run-as-service-in-ubuntu.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ menu:
identifier: "linux-service"
---

### Run as service in Ubuntu 16.04 LTS
### Run as service in Debian (and derivative distros, i.e. Ubuntu 16.04 LTS)

#### Using systemd

Expand All @@ -25,6 +25,7 @@ sudo vim /etc/systemd/system/gitea.service
Copy the sample [gitea.service](https://github.com/go-gitea/gitea/blob/master/contrib/systemd/gitea.service).

Uncomment any service that needs to be enabled on this host, such as MySQL.
Also, the service file linked above uses /root/gitea, which you may need to create.

Change the user, home directory, and other required startup values. Change the
PORT or remove the -p flag if default port is used.
Expand All @@ -35,6 +36,24 @@ sudo systemctl enable gitea
sudo systemctl start gitea
```

You can customize the ExecStart line to use a different configuration file:
```
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
```
Edit the gitea.service file as needed to use a gitea configuration stored in a non-default location.

Also configurable are the Working Directory and Environment lines in the \[Service\] section of the gitea.service file:

```
WorkingDirectory=/var/lib/gitea/
```

```
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
```

The above example lines are necessary for more customized and secure Gitea installations that do not run as the root user.
Another reason to customize the gitea.service file is running multiple separate installations on one server.

#### Using supervisor

Expand Down