Physikerwelt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/156137
Change subject: wip: mathoid role
......................................................................
wip: mathoid role
Change-Id: I6c14b350def9c24546a326ff59f6efad83a6e988
---
A puppet/modules/mathoid/manifests/init.pp
A puppet/modules/mathoid/templates/config.erb
A puppet/modules/mathoid/templates/logrotate.erb
A puppet/modules/mathoid/templates/upstart.erb
A puppet/modules/mathoid/tests/Makefile
A puppet/modules/mathoid/tests/mathoid.pp
A puppet/modules/role/manifests/mathoid.pp
7 files changed, 176 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant
refs/changes/37/156137/1
diff --git a/puppet/modules/mathoid/manifests/init.pp
b/puppet/modules/mathoid/manifests/init.pp
new file mode 100644
index 0000000..662fefb
--- /dev/null
+++ b/puppet/modules/mathoid/manifests/init.pp
@@ -0,0 +1,80 @@
+# == Class: mathoid
+#
+# mathoid is a node.js backend for the math rendering.
+#
+# === 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.
+
+#
+class mathoid(
+ $base_path,
+ $node_path,
+ $conf_path,
+ $log_dir,
+ $port=10042
+) {
+ # not required for vagrant (we clone via git here)
+ # deployment::target { 'mathoid': }
+
+ package { ['nodejs'
+ # TODO Add dependency to node-jsdom once
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742347
+ # is fixed
+ ]:
+ ensure => present,
+ }
+
+ $log_file = "${log_dir}/main.log"
+
+ file { $log_dir:
+ ensure => directory,
+ owner => mathoid,
+ group => mathoid,
+ mode => '0775',
+ }
+
+ 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'],
+ }
+}
diff --git a/puppet/modules/mathoid/templates/config.erb
b/puppet/modules/mathoid/templates/config.erb
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/puppet/modules/mathoid/templates/config.erb
@@ -0,0 +1 @@
+{}
diff --git a/puppet/modules/mathoid/templates/logrotate.erb
b/puppet/modules/mathoid/templates/logrotate.erb
new file mode 100644
index 0000000..13649f9
--- /dev/null
+++ b/puppet/modules/mathoid/templates/logrotate.erb
@@ -0,0 +1,13 @@
+#####################################################################
+### THIS FILE IS MANAGED BY PUPPET
+#####################################################################
+
+<%= @log_dir %>/* {
+ daily
+ copytruncate
+ missingok
+ compress
+ notifempty
+ rotate 15
+ size 256M
+}
diff --git a/puppet/modules/mathoid/templates/upstart.erb
b/puppet/modules/mathoid/templates/upstart.erb
new file mode 100644
index 0000000..43eb3f1
--- /dev/null
+++ b/puppet/modules/mathoid/templates/upstart.erb
@@ -0,0 +1,25 @@
+#####################################################################
+### 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/puppet/modules/mathoid/tests/Makefile
b/puppet/modules/mathoid/tests/Makefile
new file mode 100644
index 0000000..76cd656
--- /dev/null
+++ b/puppet/modules/mathoid/tests/Makefile
@@ -0,0 +1,13 @@
+MANIFESTS=$(wildcard *.pp)
+OBJS=$(MANIFESTS:.pp=.po)
+TESTS_DIR=$(dir $(CURDIR))
+MODULE_DIR=$(TESTS_DIR:/=)
+MODULES_DIR=$(dir $(MODULE_DIR))
+
+all: test
+
+test: $(OBJS)
+
+%.po: %.pp
+ puppet parser validate $<
+ puppet apply --noop --modulepath $(MODULES_DIR) $<
diff --git a/puppet/modules/mathoid/tests/mathoid.pp
b/puppet/modules/mathoid/tests/mathoid.pp
new file mode 100644
index 0000000..ff9ee0f
--- /dev/null
+++ b/puppet/modules/mathoid/tests/mathoid.pp
@@ -0,0 +1,7 @@
+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',
+}
diff --git a/puppet/modules/role/manifests/mathoid.pp
b/puppet/modules/role/manifests/mathoid.pp
new file mode 100644
index 0000000..adbbd2c
--- /dev/null
+++ b/puppet/modules/role/manifests/mathoid.pp
@@ -0,0 +1,37 @@
+class role::mathoid {
+
+ git::clone { 'mediawiki/services/mathoid':
+ owner => 'root',
+ directory => '/srv/mathoid',
+ }
+
+ class { '::mathoid':
+ base_path => '/srv/mathoid',
+ node_path => '/srv/mathoid/node_modules',
+ conf_path => '/srv/mathoid/mathoid.config.json',
+ log_dir => '/var/log/mathoid',
+ require => Git::Clone['mediawiki/services/mathoid'],
+ #require => File[ '/srv/' ]
+ }
+
+ file { '/srv/mathoid':
+ ensure => directory,
+ owner => mathoid,
+ group => mathoid,
+ mode => '755',
+ }
+
+ group { 'mathoid':
+ ensure => present,
+ name => 'mathoid',
+ system => true,
+ }
+
+ user { 'mathoid':
+ gid => 'mathoid',
+ home => '/srv/mathoid',
+ managehome => true,
+ system => true,
+ }
+
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/156137
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c14b350def9c24546a326ff59f6efad83a6e988
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits