Alexandros Kosiaris has submitted this change and it was merged.

Change subject: mathoid to service::node
......................................................................


mathoid to service::node

Have mathoid use the service::node paradigm

Bug: T97124
Change-Id: I06f06cf1f516a536b82b286551eda011c02e3a6c
---
M manifests/role/deployment.pp
M manifests/role/mathoid.pp
M modules/lvs/manifests/configuration.pp
M modules/lvs/manifests/monitor.pp
M modules/mathoid/manifests/init.pp
D modules/mathoid/templates/config.erb
D modules/mathoid/templates/logrotate.erb
D modules/mathoid/templates/upstart.erb
M modules/mathoid/tests/mathoid.pp
9 files changed, 38 insertions(+), 139 deletions(-)

Approvals:
  Alexandros Kosiaris: Verified; Looks good to me, approved



diff --git a/manifests/role/deployment.pp b/manifests/role/deployment.pp
index f59a56a..7949d66 100644
--- a/manifests/role/deployment.pp
+++ b/manifests/role/deployment.pp
@@ -41,8 +41,8 @@
             'service_name'          => 'ocg',
             'checkout_submodules'   => true,
         },
-        'mathoid/mathoid' => {
-            'upstream'              => 
'https://gerrit.wikimedia.org/r/mediawiki/services/mathoid',
+        'mathoid/deploy' => {
+            'upstream'              => 
'https://gerrit.wikimedia.org/r/mediawiki/services/mathoid/deploy',
             'service_name'          => 'mathoid',
             'checkout_submodules'   => true,
         },
diff --git a/manifests/role/mathoid.pp b/manifests/role/mathoid.pp
index 02a70d0..dec15c6 100644
--- a/manifests/role/mathoid.pp
+++ b/manifests/role/mathoid.pp
@@ -9,34 +9,5 @@
         description => 'mathoid server'
     }
 
-    class { '::mathoid':
-      require   => Package['mathoid/mathoid'],
-    }
-
-    package { 'mathoid/mathoid':
-        provider => 'trebuchet',
-    }
-
-    group { 'mathoid':
-      ensure => present,
-      name   => 'mathoid',
-      system => true,
-    }
-
-    user { 'mathoid':
-      gid        => 'mathoid',
-      home       => '/srv/deployment/mathoid/mathoid',
-      managehome => true,
-      system     => true,
-    }
-
-    ferm::service { 'mathoid':
-      proto => 'tcp',
-      port  => '10042'
-    }
-
-    monitoring::service { 'mathoid':
-      description   => 'mathoid',
-      check_command => 'check_http_on_port!10042',
-    }
+    include ::mathoid
 }
diff --git a/modules/lvs/manifests/configuration.pp 
b/modules/lvs/manifests/configuration.pp
index c8623dd..68b264b 100644
--- a/modules/lvs/manifests/configuration.pp
+++ b/modules/lvs/manifests/configuration.pp
@@ -664,7 +664,7 @@
             'bgp' => 'yes',
             'depool-threshold' => '.5',
             'monitors' => {
-                'ProxyFetch' => { 'url' => [ 'http://mathoid.svc.eqiad.wmnet' 
] },
+                'ProxyFetch' => { 'url' => [ 
'http://mathoid.svc.eqiad.wmnet/_info' ] },
                 'IdleConnection' => $idleconnection_monitor_options,
             },
         },
diff --git a/modules/lvs/manifests/monitor.pp b/modules/lvs/manifests/monitor.pp
index f7a6e0c..a0e42f1 100644
--- a/modules/lvs/manifests/monitor.pp
+++ b/modules/lvs/manifests/monitor.pp
@@ -14,7 +14,7 @@
     lvs::monitor_service_http { "parsoid.svc.eqiad.wmnet": ip_address => 
"10.2.2.28", check_command => "check_http_on_port!8000", contact_group => 
"admins,parsoid" }
     lvs::monitor_service_http { "search.svc.eqiad.wmnet": ip_address => 
"10.2.2.30", check_command => "check_http_on_port!9200", contact_group => 
"admins" }
     lvs::monitor_service_http { 'ocg.svc.eqiad.wmnet': ip_address => 
$ip['ocg']['eqiad'], check_command => 
"check_http_lvs_on_port!ocg.svc.eqiad.wmnet!8000!/?command=health" }
-    lvs::monitor_service_http { 'mathoid.svc.eqiad.wmnet': ip_address => 
$ip['mathoid']['eqiad'], check_command => 
"check_http_lvs_on_port!mathoid.svc.eqiad.wmnet!10042!/" }
+    lvs::monitor_service_http { 'mathoid.svc.eqiad.wmnet': ip_address => 
$ip['mathoid']['eqiad'], check_command => 
"check_http_lvs_on_port!mathoid.svc.eqiad.wmnet!10042!/_info" }
     lvs::monitor_service_http { 'citoid.svc.eqiad.wmnet': ip_address => 
$ip['citoid']['eqiad'], check_command => 
"check_http_lvs_on_port!citoid.svc.eqiad.wmnet!1970!/", contact_group => 
"admins,parsoid" }
     lvs::monitor_service_http { 'cxserver.svc.eqiad.wmnet': ip_address => 
$ip['cxserver']['eqiad'], check_command => 
"check_http_lvs_on_port!citoid.svc.eqiad.wmnet!8080!/" }
     lvs::monitor_service_http { 'graphoid.svc.eqiad.wmnet': ip_address => 
$ip['graphoid']['eqiad'], check_command => 
"check_http_lvs_on_port!graphoid.svc.eqiad.wmnet!19000!/_info", contact_group 
=> "admins,parsoid" }
diff --git a/modules/mathoid/manifests/init.pp 
b/modules/mathoid/manifests/init.pp
index e9b44c1..fdbd761 100644
--- a/modules/mathoid/manifests/init.pp
+++ b/modules/mathoid/manifests/init.pp
@@ -1,73 +1,46 @@
 # == Class: mathoid
 #
-# mathoid is a node.js backend for the math rendering.
+# Mathoid is an application which takes various forms of math input and
+# converts it to MathML + SVG output. It is a web-service implemented
+# in node.js.
 #
 # === Parameters
 #
-# [*base_path*]
-#   Path to the mathoid code.
-# [*node_path*]
-#   Path to the node modules mathoid depends on.
-# [*conf_path*]
-#   Where to place the config file.
-# [*log_dir*]
-#   Place where mathoid can put log files. Assumed to be already existing and
-#   have write access to mathoid user.
-# [*port*]
-#   Port where to run the mathoid service. Defaults to 10042.
+# [*svg_generation*]
+#   Enable SVG generation
+# [*img_generation*]
+#   Enable IMG generation.
+# [*png_generation*]
+#   Enable PNG generation. This is done via shelling out to Java and temporary
+#   files, so it might be insecure.
+# [*speakText_generation*]
+#   Enable speakText generation.
 #
 class mathoid(
-    $base_path = '/srv/deployment/mathoid/mathoid',
-    $node_path = '/srv/deployment/mathoid/mathoid/node_modules',
-    $conf_path = '/srv/deployment/mathoid/mathoid/mathoid.config.json',
-    $log_dir = '/var/log/mathoid',
-    $port=10042
+    $svg_generation=true,
+    $img_generation=true,
+    $png_generation=false,
+    $speakText_generation=false,
 ) {
-    require_package('nodejs')
-    # TODO Add dependency to node-jsdom once
-    # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742347
-    # is fixed
 
-    $log_file = "${log_dir}/main.log"
+    # Pending fix for 
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742347>
+    # require_package('node-jsdom')
 
-    file { $log_dir:
-        ensure => directory,
-        owner  => mathoid,
-        group  => mathoid,
-        mode   => '0775',
+    $require = undef
+    if $png_generation {
+        require_package('openjdk-7-jre-headless')
+        $require = Package['openjdk-7-jre-headless']
     }
 
-    file { $conf_path:
-        ensure  => present,
-        owner   => mathoid,
-        group   => mathoid,
-        mode    => '0555',
-        content => template('mathoid/config.erb'),
-    }
-
-    # The upstart configuration
-    file { '/etc/init/mathoid.conf':
-        ensure  => present,
-        owner   => root,
-        group   => root,
-        mode    => '0444',
-        content => template('mathoid/upstart.erb'),
-    }
-
-    file { '/etc/logrotate.d/mathoid':
-        ensure  => present,
-        owner   => root,
-        group   => root,
-        mode    => '0444',
-        content => template('mathoid/logrotate.erb'),
-    }
-
-    service { 'mathoid':
-        ensure     => running,
-        hasstatus  => true,
-        hasrestart => true,
-        provider   => 'upstart',
-        require    => File[$log_dir],
-        subscribe  => File['/etc/init/mathoid.conf'],
+    service::node { 'mathoid':
+        port            => 10042,
+        config          => {
+            svg       => $svg_generation,
+            img       => $img_generation,
+            png       => $png_generation,
+            speakText => $speakText_generation,
+        },
+        healthcheck_url => '/_info',
+        require         => $require,
     }
 }
diff --git a/modules/mathoid/templates/config.erb 
b/modules/mathoid/templates/config.erb
deleted file mode 100644
index 0967ef4..0000000
--- a/modules/mathoid/templates/config.erb
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/modules/mathoid/templates/logrotate.erb 
b/modules/mathoid/templates/logrotate.erb
deleted file mode 100644
index 13649f9..0000000
--- a/modules/mathoid/templates/logrotate.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-#####################################################################
-
-<%= @log_dir %>/* {
-    daily
-    copytruncate
-    missingok
-    compress
-    notifempty
-    rotate 15
-    size 256M
-}
diff --git a/modules/mathoid/templates/upstart.erb 
b/modules/mathoid/templates/upstart.erb
deleted file mode 100644
index 43eb3f1..0000000
--- a/modules/mathoid/templates/upstart.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-#####################################################################
-
-description "Mathoid HTTP service"
-
-start on (local-filesystems and net-device-up IFACE!=lo)
-stop on runlevel [!2345]
-
-# up ulimit -n a bit
-limit nofile 10000 10000
-
-setuid "mathoid"
-setgid "mathoid"
-
-env NODE_PATH="<%= @node_path %>"
-env MATHOID_PORT="<%= @port %>"
-
-respawn
-
-# wait 60 seconds for a graceful restart before killing the master
-kill timeout 60
-
-chdir "<%= @base_path %>"
-exec /usr/bin/nodejs mathoid.js >> "<%= @log_file %>" 2>&1
diff --git a/modules/mathoid/tests/mathoid.pp b/modules/mathoid/tests/mathoid.pp
index ff9ee0f..1f030cd 100644
--- a/modules/mathoid/tests/mathoid.pp
+++ b/modules/mathoid/tests/mathoid.pp
@@ -1,7 +1 @@
-class { 'mathoid':
-    base_path => '/tmp/mathoid/',
-    node_path => '/tmp/mathoid/node_modules',
-    conf_path => '/tmp/mathoid/config.config.json',
-    log_dir   => '/var/log/mathoid',
-    port   => '10042',
-}
+class { 'mathoid': }

-- 
To view, visit https://gerrit.wikimedia.org/r/167413
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I06f06cf1f516a536b82b286551eda011c02e3a6c
Gerrit-PatchSet: 16
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to