Skip to content

Commit 471ee56

Browse files
committed
Add first draft of systemd services. Fix #14 Implement #43
1 parent 2f555a5 commit 471ee56

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

init/systemd/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## GitLab startup services for systemd (Archlinux, Fedora, etc)
2+
3+
GitLab requires a couple of services:
4+
* Web server (apache, nginx, etc.)
5+
* Redis server
6+
* Mail server (postfix or other)
7+
* GitLab Sidekiq service (`gitlab-sidekiq.service`)
8+
* Unicorn (`gitlab-unicorn.service`)
9+
10+
11+
## Setup GitLab Sidekiq service
12+
13+
Copy files to `/etc/systemd/system/`:
14+
15+
```
16+
su -
17+
cd /etc/systemd/system/
18+
wget -O gitlab-sidekiq.service https://raw.github.com/gitlabhq/gitlab-recipes/master/init/systemd/gitlab-sidekiq.service
19+
wget -O gitlab-unicorn.service https://raw.github.com/gitlabhq/gitlab-recipes/master/init/systemd/gitlab-unicorn.service
20+
wget -O gitlab.target https://raw.github.com/gitlabhq/gitlab-recipes/master/init/systemd/gitlab.target
21+
```
22+
23+
Reload systemd:
24+
25+
sudo systemctl --system daemon-reload
26+
27+
Start the services:
28+
29+
sudo systemctl start gitlab-sidekiq gitlab-unicorn
30+
31+
Enable them to start at boot:
32+
33+
sudo systemctl enable gitlab-sidekiq gitlab-unicorn
34+
35+
## Notes
36+
37+
If you installed GitLab in other path than `/home/git/gitlab` change the service files accordingly.
38+
39+
`/etc/systemd/system/` have a higher precedence over `/lib/systemd/system`.
40+
41+
For older systemd versions you need to append `service` after the service name. For example:
42+
43+
sudo systemctl start gitlab-sidekiq.service

init/systemd/gitlab-sidekiq.service

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[Unit]
2+
Description=GitLab Sidekiq Worker
3+
Requires=redis.service
4+
After=syslog.target network.target redis.service
5+
Wants=mysqld.service
6+
7+
[Service]
8+
Type=forking
9+
User=git
10+
WorkingDirectory=/home/git/gitlab
11+
Environment=RAILS_ENV=production
12+
SyslogIdentifier=gitlab-sidekiq
13+
PidFile=/home/git/gitlab/tmp/pids/sidekiq.pid
14+
15+
ExecStart=/usr/bin/bundle exec rake sidekiq:start
16+
ExecStop=/usr/bin/bundle exec rake sidekiq:stop
17+
18+
[Install]
19+
WantedBy=gitlab.target

init/systemd/gitlab-unicorn.service

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=GitLab Unicorn Server
3+
Requires=redis.service
4+
After=network.target mysqld.service redis.service
5+
6+
[Service]
7+
User=git
8+
WorkingDirectory=/home/git/gitlab
9+
Environment=RAILS_ENV=production
10+
SyslogIdentifier=gitlab-unicorn
11+
PidFile=/home/git/gitlab/tmp/pids/unicorn.pid
12+
13+
ExecStart=/usr/bin/bundle exec "unicorn_rails -c /home/git/gitlab/config/unicorn.rb -E production"
14+
15+
[Install]
16+
WantedBy=gitlab.target

init/systemd/gitlab.target

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Unit]
2+
Description=GitLab - Self Hosted Git Management
3+
4+
[Install]
5+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)