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 (
|
||||
$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"] ]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
14
templates/askbot-celeryd.service.erb
Normal file
14
templates/askbot-celeryd.service.erb
Normal 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
|
Loading…
x
Reference in New Issue
Block a user