diff --git a/site-modules/profile/manifests/swh/deploy/worker/base.pp b/site-modules/profile/manifests/swh/deploy/worker/base.pp index 8c3b801a..14ed959e 100644 --- a/site-modules/profile/manifests/swh/deploy/worker/base.pp +++ b/site-modules/profile/manifests/swh/deploy/worker/base.pp @@ -1,43 +1,45 @@ # Base worker profile class profile::swh::deploy::worker::base { $systemd_template_unit_name = 'swh-worker@.service' $systemd_unit_name = 'swh-worker.service' $systemd_slice_name = 'system-swh\x2dworker.slice' + $celery_hostname = $swh_hostname['internal_fqdn'] + package {'python3-swh.scheduler': ensure => installed, } ::systemd::unit_file {$systemd_template_unit_name: ensure => 'present', - source => "puppet:///modules/profile/swh/deploy/worker/${systemd_template_unit_name}", + content => template("profile/swh/deploy/worker/${systemd_template_unit_name}.erb"), } ::systemd::unit_file {$systemd_unit_name: ensure => 'present', source => "puppet:///modules/profile/swh/deploy/worker/${systemd_unit_name}", } ~> service {'swh-worker': ensure => running, enable => true, } ::systemd::unit_file {$systemd_slice_name: ensure => 'present', source => "puppet:///modules/profile/swh/deploy/worker/${systemd_slice_name}", } profile::cron::d {'cleanup-workers-tmp': command => 'find /tmp -depth -mindepth 3 -maxdepth 3 -type d -ctime +2 -exec rm -rf {} \+', target => 'swh-worker', minute => 'fqdn_rand', hour => 'fqdn_rand/2', } file {'/usr/local/sbin/swh-worker-ping-restart': source => 'puppet:///profile/swh/deploy/worker/swh-worker-ping-restart', owner => 'root', group => 'root', mode => '0755', } } diff --git a/site-modules/profile/files/swh/deploy/worker/swh-worker@.service b/site-modules/profile/templates/swh/deploy/worker/swh-worker@.service.erb similarity index 53% rename from site-modules/profile/files/swh/deploy/worker/swh-worker@.service rename to site-modules/profile/templates/swh/deploy/worker/swh-worker@.service.erb index 452ccbdc..ef0dde59 100644 --- a/site-modules/profile/files/swh/deploy/worker/swh-worker@.service +++ b/site-modules/profile/templates/swh/deploy/worker/swh-worker@.service.erb @@ -1,27 +1,28 @@ [Unit] Description=Software Heritage Worker (%i) After=network.target [Service] User=swhworker Group=swhworker Type=simple Environment=SWH_CONFIG_FILENAME=/etc/softwareheritage/%i.yml Environment=SWH_LOG_TARGET=journal Environment=CONCURRENCY=10 Environment=MAX_TASKS_PER_CHILD=5 Environment=LOGLEVEL=info -ExecStart=/usr/bin/python3 -m celery worker -n %i.%%h --app=swh.scheduler.celery_backend.config.app --pool=prefork --events --concurrency=${CONCURRENCY} --maxtasksperchild=${MAX_TASKS_PER_CHILD} -Ofair --loglevel=${LOGLEVEL} --without-gossip --without-mingle --without-heartbeat +Environment=CELERY_HOSTNAME=<%= @celery_hostname %> +ExecStart=/usr/bin/python3 -m celery worker -n %i@${CELERY_HOSTNAME} --app=swh.scheduler.celery_backend.config.app --pool=prefork --events --concurrency=${CONCURRENCY} --maxtasksperchild=${MAX_TASKS_PER_CHILD} -Ofair --loglevel=${LOGLEVEL} --without-gossip --without-mingle --without-heartbeat KillMode=process KillSignal=SIGTERM TimeoutStopSec=15m OOMPolicy=kill Restart=always RestartSec=10 [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target