Add systemd support
This adds a basic service file for celeryd and associated bits to install it on Xenial and beyond. Change-Id: I58ab956832acabf9e5af5f815e37ed1eb365a649
This commit is contained in:
parent
a80352f938
commit
adfb969dcf
|
@ -3,20 +3,51 @@
|
||||||
class askbot::site::celeryd (
|
class askbot::site::celeryd (
|
||||||
$site_root,
|
$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':
|
if ($::operatingsystem == 'Ubuntu') and versioncmp($::operatingsystemrelease, '16.04') >= 0 {
|
||||||
ensure => running,
|
|
||||||
enable => true,
|
file { '/etc/systemd/system/askbot-celeryd.service':
|
||||||
hasrestart => true,
|
ensure => present,
|
||||||
require => File['/etc/init/askbot-celeryd.conf'],
|
owner => 'root',
|
||||||
subscribe => [ Exec['askbot-migrate'], File["${site_root}/config/settings.py"] ]
|
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"] ]
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue