I am currently writing a Puppet module to get GitLab running on CentOS 6/7. For the CentOS 7 install I need to write a systemd unit file to start the gitlab service (which is actually Unicorn & Sidekiq).
Here's the unit file I came up with based on my vague understanding of the init script that GitLab themselves provide:
[Unit]
Description=GitLab
After=network.target
Requires=network.target
After=mariadb.service
Requires=mariadb.service
After=redis.service
Requires=redis.service
[Service]
EnvironmentFile=/etc/sysconfig/gitlab
ExecStartPre=source /etc/profile.d/rvm.sh
ExecStart=/bin/bash --pidfile=$UPID --user=$USER "$PATH_PATCH RAILS_ENV=$RAILS_ENV bin/web start" && /bin/bash --pidfile=$SPID --user=$USER "$PATH_PATCH RAILS_ENV=$RAILS_ENV bin/background_jobs start"
[Install]
WantedBy=multi-user.target
And here is the associated sysconfig file:
RAILS_ENV="production"
USER=git
APP_PATH=/home/$USER/gitlab
UPID=$APP_PATH/tmp/pids/unicorn.pid
ULOCK=/var/lock/subsys/unicorn
SPID=$APP_PATH/tmp/pids/sidekiq.pid
SLOCK=/var/lock/subsys/sidekiq
PATH_PATCH="PATH=$(su $USER -s /bin/bash -l -c "echo \"\$PATH\"") && export PATH && "
This does not work in the slightest (not unexpected):
[root@gitlab ~]# systemctl status gitlab -l
gitlab.service - GitLab
Loaded: loaded (/usr/lib/systemd/system/gitlab.service; disabled)
Active: failed (Result: exit-code) since Fri 2015-04-17 15:48:38 BST; 6s ago
Process: 9942 ExecStart=/bin/bash --pidfile=$UPID --user=$USER $PATH_PATCH RAILS_ENV=$RAILS_ENV bin/web start && /bin/bash --pidfile=$SPID --user=$USER $PATH_PATCH RAILS_ENV=$RAILS_ENV bin/background_jobs start (code=exited, status=2)
Main PID: 9942 (code=exited, status=2)
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: --rcfile
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: --rpm-requires
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: --restricted
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: --verbose
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: --version
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: Shell options:
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: -irsD or -c command or -O shopt_option (invocation only)
Apr 17 15:48:38 gitlab.thefallenphoenix.net bash[9942]: -abefhkmnptuvxBCHP or -o option
Apr 17 15:48:38 gitlab.thefallenphoenix.net systemd[1]: gitlab.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Apr 17 15:48:38 gitlab.thefallenphoenix.net systemd[1]: Unit gitlab.service entered failed state.
Can anyone shed some light over what exactly is needed here or point me in the right direction?