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

provide systemd unit file #14

Closed
katanacrimson opened this issue Oct 23, 2012 · 12 comments
Closed

provide systemd unit file #14

katanacrimson opened this issue Oct 23, 2012 · 12 comments

Comments

@katanacrimson
Copy link

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
Copy link
Contributor

vsizov commented Oct 23, 2012

What OS do you use?

@katanacrimson
Copy link
Author

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
Copy link

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.

@katanacrimson
Copy link
Author

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
Copy link

japgolly commented Nov 1, 2012

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

@katanacrimson
Copy link
Author

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
Copy link

japgolly commented Nov 2, 2012

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?

@katanacrimson
Copy link
Author

@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
Copy link

japgolly commented Nov 2, 2012

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.

@katanacrimson
Copy link
Author

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

@veprbl
Copy link

veprbl commented Mar 8, 2013

@axilleas
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants