provide systemd unit file #14

Closed
damianb opened this Issue Oct 23, 2012 · 12 comments

5 participants

@damianb

Would be nice if there was a systemd unit file (for us arch users) along with the init.d script.

If nobody else takes a swing at it, when I get a chance I'll give it a shot. Would be nice too considering that systemd would allow for starting gitlab once redis/resque are up (the proper dependency startup is quite nice)

@vsizov

What OS do you use?

@damianb

I'm just one of those crazy damn arch linux users.

For what it's worth, RHEL and distros based on it are confirmed to be moving to systemd (replacing upstart and sysvinit) in the future, so might as well get ahead of the game.

@japgolly

This would be great. Many distros are adopting systemd and apparently the unit files (equivilent of init.d scripts) are pretty easy to write. See: http://fedoraproject.org/wiki/Packaging:Systemd#Unit_Files

OSs that currently use systemd:

  • Arch Linux
  • Fedora 15+
  • Frugalware 1.5+
  • Mageia 2
  • Mandriva 2011+
  • openSUSE 12.1+

OSs soon/likely to be moving to / supporting systemd:

  • Debian
  • Gentoo
  • Red Hat Enterprise Linux 7

Also:

systemd has been proposed as an external dependency of GNOME 3.2 by the project's author.[8] This would essentially require all distributions that use GNOME to use systemd, or at least include it as a configurable option.

@damianb

Also:

systemd has been proposed as an external dependency of GNOME 3.2 by the project's author.[8] This would essentially require all distributions that use GNOME to use systemd, or at least include it as a configurable option.

gnome 3.6 was just recently released fyi - still no dependency on it that I know of.

Another good resource: https://wiki.archlinux.org/index.php/Systemd#Writing_custom_.service_files

@japgolly

Hi. I got round to doing this so here it is below. Man! Now that I've learnt systemd, it really like it!!

/etc/systemd/system/gitlab.service:

[Unit]
Description=Self Hosted Git Management
Requires=postgresql.service redis.service
After=postgresql.service redis.service
Wants=postfix.service gitlab-worker.service

[Service]
Type=forking
User=gitlab
WorkingDirectory=/home/gitlab/gitlab
ExecStart=/home/gitlab/gitlab/script/rails server -d -e production
PIDFile=/home/gitlab/gitlab/tmp/pids/server.pid

[Install]
WantedBy=multi-user.target

/etc/systemd/system/gitlab-worker.service:

[Unit]
Description=Gitlab Resque Worker
Requires=redis.service
After=redis.service
Wants=postfix.service postgresql.service

[Service]
Type=forking
User=gitlab
WorkingDirectory=/home/gitlab/gitlab
ExecStart=/bin/bash -c '. ~/.bashrc; . ./resque.sh'
ExecStopPost=/usr/bin/rm /home/gitlab/gitlab/tmp/pids/resque_worker.pid
PIDFile=/home/gitlab/gitlab/tmp/pids/resque_worker.pid
@damianb

should note that will only work for gitlab+pgsql installations.

perhaps it shouldn't use a wants for postgresql? i imagine, because it is sqlite compatible too, it could just want postgres and mysql, and not require either.

@japgolly

Yeah I agree, it would be problematic if this were installed indiscriminately. I don't know that there's a way to create a single file that will be solid for sqlite/mysql/postgresql users. This works well for me on postgresql. Maybe if this is installed via script or something then it can substitute or remove with regex?

@damianb

@japgolly Looking at the arch wiki, I'd say that just using wants+after would be most appropriate.

If the dependency is optional, add Wants=B and After=B instead.

So, by moving postgres out of Requires and into Wants (and keeping it in After) it should allow it to work properly with neither present or with one of the two installed.

@japgolly

I see what you're saying but the problem with that is when people are using postgresql or mysql, it's not optional. For their installations requires=postgres or requires=mysql is valid and accurate. Like on my installation it shouldn't try to bring up gitlab if postgresql fails.

I think people should keep the units the way they are but either change postgresql to mysql or remove it completely if they use sqlite.

@damianb

Seeing as sqlite support is being dropped, looks like it'll be postgres/mysql only here.

@axilleas axilleas referenced this issue Aug 5, 2013
Merged

[WIP] New repository structure #111

12 of 14 tasks complete
@axilleas axilleas was assigned Aug 5, 2013
@axilleas
GitLab member

I provided some service files based on many suggestions that play with Fedora (see above commit). Haven't tested with Arch yet. Feedback welcomed :)

@axilleas axilleas closed this Aug 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment