Commit cd17a9fe authored by Héctor Orón Martínez's avatar Héctor Orón Martínez

Merge branch 'obs-api-systemd-unit-files' into 'debian/master'

Obs api systemd unit files

See merge request !18
parents 91adacfd 5d17d585
......@@ -14,5 +14,5 @@ usr/share/obs/overview/overview.html.TEMPLATE
debian/rake-tasks.sh /usr/share/obs/api/script/
debian/systemd/obsapidelayed.service /lib/systemd/system/
debian/systemd/obsapi* /lib/systemd/system/
......@@ -11,6 +11,15 @@ if ! getent passwd obsapi > /dev/null; then
usermod -c "User for build service api/webui" obsapi
fi
# regenerate Gemfile.lock
rm -f /usr/share/obs/api/Gemfile.lock
cd /usr/share/obs/api
# previous bundle config does not allow one to regenerate the Gemfile.lock
rm -f .bundle/config || true
bundle --local --quiet
cd - >/dev/null
chown www-data:www-data /usr/share/obs/api/Gemfile.lock
# Place api and repo url on index page
if [ ! -f /usr/share/obs/overview/index.html ] ; then
FQHOSTNAME=`hostname -f` || FQHOSTNAME=obs-api
......@@ -50,6 +59,9 @@ fi
touch /var/log/obs/production.sphinx.pid
touch /var/log/obs/clockworkd.clock.output
chown -R www-data:www-data /var/log/obs
chown -R www-data:www-data /var/cache/obs/tmp
# Config Database with dbconfig-common
. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/postinst.mysql
......
......@@ -63,14 +63,18 @@ case "$1" in
run_in_api rake assets:precompile RAILS_ENV=production RAILS_GROUPS=assets
run_in_api rake ts:index RAILS_ENV=production || true
# Start up obsapidelayed
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d obsapidelayed restart 3>/dev/null || true && \
echo "obsapidelayed restarted."
else
/etc/init.d/obsapidelayed restart 3>/dev/null || true && \
echo "obsapidelayed restarted."
fi
# Start up obsapi daemons
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d obsapi-clockwork.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-consistency_check.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-default.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-issuetracking.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-mailers.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-project_log_rotate.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-quick.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-releasetracking.service restart 3>/dev/null || true
echo "obsapi restarted."
fi
# Test whether a2enmod is available (and thus also apache2ctl).
......
......@@ -84,10 +84,18 @@ override_dh_systemd_enable:
obspublisher.service \
obsservice.service \
obssigner.service
dh_systemd_enable -p obs-api obsapidelayed.service
dh_systemd_enable -p obs-api \
obsapi.target \
obsapi-clockwork.service \
obsapi-delayedjob-queue-consistency_check.service \
obsapi-delayedjob-queue-default.service \
obsapi-delayedjob-queue-issuetracking.service \
obsapi-delayedjob-queue-mailers.service \
obsapi-delayedjob-queue-project_log_rotate.service \
obsapi-delayedjob-queue-quick.service \
obsapi-delayedjob-queue-releasetracking.service
override_dh_installinit:
dh_installinit --name obsapidelayed --no-start
dh_installinit --name obsworker --no-enable
override_dh_systemd_start:
......@@ -101,7 +109,16 @@ override_dh_systemd_start:
obspublisher.service \
obsservice.service \
obssigner.service
dh_systemd_start -p obs-api obsapidelayed.service
dh_systemd_start -p obs-api \
obsapi.target \
obsapi-clockwork.service \
obsapi-delayedjob-queue-consistency_check.service \
obsapi-delayedjob-queue-default.service \
obsapi-delayedjob-queue-issuetracking.service \
obsapi-delayedjob-queue-mailers.service \
obsapi-delayedjob-queue-project_log_rotate.service \
obsapi-delayedjob-queue-quick.service \
obsapi-delayedjob-queue-releasetracking.service
override_dh_auto_test:
dh_auto_test || true # temporary ignore
[Unit]
Description=OBS API clockwork service
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec /usr/bin/clockworkd --log-dir=log --pid-dir=tmp/pids -l -c config/clock.rb start
ExecStop=/usr/bin/bundle exec /usr/bin/clockworkd --log-dir=log --pid-dir=tmp/pids -l -c config/clock.rb stop
PIDFile=/var/cache/obs/tmp/pids/clockworkd.clock.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: consistency_check
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=consistency_check start -i 1050
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=consistency_check stop -i 1050
PIDFile=/var/cache/obs/tmp/pids/delayed_job.1050.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: default
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=default start -i 1030
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=default stop -i 1030
PIDFile=/var/cache/obs/tmp/pids/delayed_job.1030.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: issuetracking
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=issuetracking start -i 1010
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=issuetracking stop -i 1010
PIDFile=/var/cache/obs/tmp/pids/delayed_job.1010.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: mailers
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=mailers start -i 1020
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=mailers stop -i 1020
PIDFile=/var/cache/obs/tmp/pids/delayed_job.1020.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: project_log_rotate
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=project_log_rotate start -i 1040
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=releasetracking stop -i 1040
PIDFile=/var/cache/obs/tmp/pids/delayed_job.1040.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: quick
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=quick start -i 3
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=quick stop -i 3
PIDFile=/var/cache/obs/tmp/pids/delayed_job.3.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API DelayedJob queue: releasetracking
BindsTo=obsapi.target
[Service]
Type=forking
EnvironmentFile=/etc/default/obs-server
WorkingDirectory=/usr/share/obs/api
User=www-data
Group=www-data
Environment="RAILS_ENV=production"
ExecStart=/usr/bin/bundle exec script/delayed_job.api.rb --queue=releasetracking start -i 1000
ExecStop=/usr/bin/bundle exec script/delayed_job.api.rb --queue=releasetracking stop -i 1000
PIDFile=/var/cache/obs/tmp/pids/delayed_job.1000.pid
[Install]
WantedBy=obsapi.target
[Unit]
Description=OBS API Support Daemons
Wants=obsapi-clockwork.service obsapi-delayedjob-queue-consistency_check.service obsapi-delayedjob-queue-default.service obsapi-delayedjob-queue-issuetracking.service obsapi-delayedjob-queue-mailers.service obsapi-delayedjob-queue-project_log_rotate.service obsapi-delayedjob-queue-quick.service obsapi-delayedjob-queue-releasetracking.service
After=network.target
AllowIsolate=yes
[Install]
WantedBy=multi-user.target
[Unit]
Description=OBS API Delayed server
After=network.target
[Service]
EnvironmentFile=/etc/default/obs-server
ExecStart=/bin/bash -c "/usr/bin/echo -n 'Starting OBS api delayed job handler'"
ExecStart=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=quick start -n 3"
ExecStart=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=releasetracking start -i 1000"
ExecStart=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=issuetracking start -i 1010"
ExecStart=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=mailers start -i 1020"
ExecStart=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb start -i 1030"
ExecStart=/bin/bash -c "/usr/bin/echo -n 'Starting OBS api clock daemon'"
ExecStart=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec /usr/bin/clockworkd --log-dir=log -l -c config/clock.rb start"
ExecStop=/bin/bash -c "/usr/bin/echo -n 'Shutting down OBS api delayed job handler'"
ExecStop=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=quick stop -n 3"
ExecStop=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=releasetracking stop -i 1000"
ExecStop=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=issuetracking stop -i 1010"
ExecStop=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb --queue=mailers stop -i 1020"
ExecStop=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec script/delayed_job.api.rb stop -i 1030"
ExecStop=/bin/bash -c "/usr/bin/echo -n 'Shutting down OBS api clock daemon'"
ExecStop=chroot --userspec=www-data:www-data / /bin/bash -c "cd /usr/share/obs/api && /usr/bin/bundle exec /usr/bin/clockworkd --log-dir=log -l -c config/clock.rb stop"
KillMode=process
[Install]
WantedBy=multi-user.target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment