Alexandros Kosiaris has submitted this change and it was merged. Change subject: Apertium: Add -j -m and parameters ......................................................................
Apertium: Add -j -m and parameters Used base::service_unit to populate upstart and systemd unit files that allows to: -j - Number of APY instance processes to run -m - Seconds to wait before shutdown idle process We've set -j 1 and -m 300 for production. Change-Id: Id386c9964c844c9a37e4c2f311b61c17e1b02154 --- M modules/apertium/manifests/init.pp A modules/apertium/templates/initscripts/apertium-apy.systemd.erb A modules/apertium/templates/initscripts/apertium-apy.upstart.erb 3 files changed, 54 insertions(+), 4 deletions(-) Approvals: Alexandros Kosiaris: Verified; Looks good to me, approved diff --git a/modules/apertium/manifests/init.pp b/modules/apertium/manifests/init.pp index 6781eb0..7008178 100644 --- a/modules/apertium/manifests/init.pp +++ b/modules/apertium/manifests/init.pp @@ -3,7 +3,16 @@ # Apertium is a backend Machine Translation service for the Content Translation. # https://www.mediawiki.org/wiki/Content_translation/Apertium # -class apertium(){ +# === Parameters +# +# [*num_of_processes*] +# Number of APY instance processes to run +# [*max_idle_seconds*] +# Seconds to wait before shutdown idle process +class apertium( + $num_of_processes = 1, + $max_idle_seconds = 300, +) { package { [ 'apertium', 'apertium-af-nl', @@ -54,8 +63,15 @@ notify => Service['apertium-apy'], } - service { 'apertium-apy': - ensure => running, - require => Package['apertium-apy'], + base::service_unit { 'apertium-apy': + ensure => present, + upstart => true, + systemd => true, + refresh => true, + service_params => { + enable => true, + hasstatus => true, + hasrestart => true, + } } } diff --git a/modules/apertium/templates/initscripts/apertium-apy.systemd.erb b/modules/apertium/templates/initscripts/apertium-apy.systemd.erb new file mode 100644 index 0000000..266313c --- /dev/null +++ b/modules/apertium/templates/initscripts/apertium-apy.systemd.erb @@ -0,0 +1,16 @@ +# NOTE: This file is managed by Puppet +# Systemd unit for <%= @title %> +[Unit] +Description="<%= @title %> service" + +[Service] +User=apertium +Group=apertium +Restart=always +RestartSec=2s +# wait 60 seconds for a graceful restart before killing the master +TimeoutStopSec=60 +ExecStart=/usr/bin/python3 /usr/share/apertium-apy/servlet.py -j<%= @num_of_processes %> -m<%= @max_idle_seconds %> /usr/share/apertium/modes + +[Install] +WantedBy=multi-user.target diff --git a/modules/apertium/templates/initscripts/apertium-apy.upstart.erb b/modules/apertium/templates/initscripts/apertium-apy.upstart.erb new file mode 100644 index 0000000..ae65eb4 --- /dev/null +++ b/modules/apertium/templates/initscripts/apertium-apy.upstart.erb @@ -0,0 +1,18 @@ +##################################################################### +### THIS FILE IS MANAGED BY PUPPET +##################################################################### + +description "Apertium APY service" + +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [!2345] + +setuid "apertium" +setgid "apertium" + +env LC_ALL=en_US.utf-8 + +exec /usr/bin/python3 /usr/share/apertium-apy/servlet.py -j<%= @num_of_processes %> -m<%= @max_idle_seconds %> /usr/share/apertium/modes + +# wait 60 seconds for a graceful restart before killing the master +kill timeout 60 -- To view, visit https://gerrit.wikimedia.org/r/230108 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id386c9964c844c9a37e4c2f311b61c17e1b02154 Gerrit-PatchSet: 5 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: KartikMistry <[email protected]> Gerrit-Reviewer: Alexandros Kosiaris <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
