Run as systemd service ubuntu (#149)

* Run as service in Ubuntu 16.04 via supervisor

* Updated mkdir command as sudo not required for user home dir

* Updates: added empty lines, ref and fixed few typos

* Updates: added empty line

* Updates: added identifier changes

* Newline after Run as service line

* Added systemd service

* Removed systemd title

* Fix typo

* Fixed invalid MD syntax, moved systemd to the top

* Removed code part
This commit is contained in:
Arif
2017-09-06 05:31:39 +08:00
committed by Lauris BH
parent 32df387c8f
commit 0a31ea51b9
@@ -15,39 +15,54 @@ menu:
### Run as service in Ubuntu 16.04 LTS
#### Using systemd
Run below command in terminal:
```
sudo vim /etc/systemd/system/gitea.service
```
Add code to the file from [here](https://github.com/go-gitea/gitea/blob/master/contrib/systemd/gitea.service).
Uncomment any service need to be enabled like mysql in this case in Unit section.
Change the user(git) accordingly to yours. And /home/git too if your username is different than git. Change the PORT or remove the -p flag if default port is used.
Lastly start and enable gitea at boot:
```
sudo systemctl start gitea
```
```
sudo systemctl enable gitea
```
#### Using supervisor
Install supervisor by running below command in terminal:
```sudo apt install supervisor```
```
sudo apt install supervisor
```
Create a log dir for the supervisor logs(assuming gitea is installed in /home/git/gitea/):
```mkdir /home/git/gitea/log/supervisor```
```
mkdir /home/git/gitea/log/supervisor
```
Open supervisor config file in vi/vim/nano etc.
```sudo vim /etc/supervisor/supervisord.conf```
And append the following code at the end of the file, [reference](https://github.com/go-gitea/gitea/blob/master/contrib/supervisor/gitea):
```
[program:gitea]
directory=/home/git/gitea/
command=/home/git/gitea/gitea web -p PORT
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/home/git/gitea/log/supervisor/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/home/git/gitea/log/supervisor/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
user = git
environment = HOME="/home/git", USER="git"
sudo vim /etc/supervisor/supervisord.conf
```
And append the code at the end of the file from [here](https://github.com/go-gitea/gitea/blob/master/contrib/supervisor/gitea).
Change the user(git) accordingly to yours. And /home/git too if your username is different than git. Change the PORT or remove the -p flag if default port is used.
Lastly start and enable supervisor at boot:
```sudo systemctl start supervisor```
```sudo systemctl enable supervisor```
```
sudo systemctl start supervisor
```
```
sudo systemctl enable supervisor
```