Merge "Add systemd support"

This commit is contained in:
Zuul 2018-07-21 14:54:26 +00:00 committed by Gerrit Code Review
commit 6d8f4c5f1c
2 changed files with 59 additions and 14 deletions

View File

@ -3,20 +3,51 @@
class askbot::site::celeryd (
$site_root,
) {
file { '/etc/init/askbot-celeryd.conf':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template('askbot/celeryd.upstart.conf.erb'),
require => Exec['askbot-migrate'],
}
service { 'askbot-celeryd':
ensure => running,
enable => true,
hasrestart => true,
require => File['/etc/init/askbot-celeryd.conf'],
subscribe => [ Exec['askbot-migrate'], File["${site_root}/config/settings.py"] ]
if ($::operatingsystem == 'Ubuntu') and versioncmp($::operatingsystemrelease, '16.04') >= 0 {
file { '/etc/systemd/system/askbot-celeryd.service':
ensure => present,
owner => 'root',
group => 'root',
content => template('askbot/askbot-celeryd.service.erb'),
require => Exec['askbot-migrate'],
}
service { 'askbot-celeryd':
ensure => running,
enable => true,
hasrestart => false,
require => File['/etc/systemd/system/askbot-celeryd.service'],
}
# This is a hack to make sure that systemd is aware of the new service
# before we attempt to start it.
exec { 'celeryd-systemd-daemon-reload':
command => '/bin/systemctl daemon-reload',
before => Service['askbot-celeryd'],
subscribe => File['/etc/systemd/system/askbot-celeryd.service'],
refreshonly => true,
}
} else {
file { '/etc/init/askbot-celeryd.conf':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template('askbot/celeryd.upstart.conf.erb'),
require => Exec['askbot-migrate'],
}
service { 'askbot-celeryd':
ensure => running,
enable => true,
hasrestart => true,
require => File['/etc/init/askbot-celeryd.conf'],
subscribe => [ Exec['askbot-migrate'], File["${site_root}/config/settings.py"] ]
}
}
}

View File

@ -0,0 +1,14 @@
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/srv/askbot-site/config
ExecStart=/usr/askbot-env/bin/python manage.py celeryd -c 5 --maxtasksperchild=1000 --time-limit=30
ExecStop=/bin/kill -INT $MAINPID
[Install]
WantedBy=multi-user.target