Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191887
Change subject: Graphoid role
......................................................................
Graphoid role
Implemented based on mathoid role
TODO: Requires 2GB RAM in VM to install, but that means that
we have to enable, run provision, reload, and run provision again.
Change-Id: I16fc80ac0aa459c20e3bd40b03fa786e889542a1
---
M .gitignore
M puppet/hieradata/common.yaml
A puppet/modules/graphoid/manifests/init.pp
A puppet/modules/graphoid/manifests/install/git.pp
A puppet/modules/graphoid/templates/config.erb
A puppet/modules/graphoid/templates/upstart.erb
A puppet/modules/role/manifests/graphoid.pp
7 files changed, 151 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant
refs/changes/87/191887/1
diff --git a/.gitignore b/.gitignore
index 6c6e165..bde4b54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@
/iegreview
/profiles
/phab
+/node_modules
diff --git a/puppet/hieradata/common.yaml b/puppet/hieradata/common.yaml
index 2580e0f..94fca28 100644
--- a/puppet/hieradata/common.yaml
+++ b/puppet/hieradata/common.yaml
@@ -114,6 +114,12 @@
mathoid::log_dir: /vagrant/logs
mathoid::port: 10042
+graphoid::base_path: /vagrant/graphoid
+graphoid::node_path: /vagrant/graphoid/node_modules
+graphoid::conf_path: /vagrant/graphoid/graphoid.config.json
+graphoid::log_dir: /vagrant/logs
+graphoid::port: 11042
+
php::sessionclean::ensure: present
iegreview::vhost_name: iegreview.local.wmftest.net
diff --git a/puppet/modules/graphoid/manifests/init.pp
b/puppet/modules/graphoid/manifests/init.pp
new file mode 100644
index 0000000..c6ea3a8
--- /dev/null
+++ b/puppet/modules/graphoid/manifests/init.pp
@@ -0,0 +1,72 @@
+# == Class: graphoid
+#
+# graphoid is a node.js backend for the graph rendering.
+#
+# === Parameters
+#
+# [*base_path*]
+# Path to the graphoid code. (e.g. /vagrant/graphoid)
+#
+# [*node_path*]
+# Path to the node modules graphoid depends on.
+# (e.g. /vagrant/graphoid/node_modules)
+#
+# [*conf_path*]
+# Where to place the config file.
+# (e.g. /vagrant/graphoid/graphoid.config.json)
+#
+# [*log_dir*]
+# Place where graphoid can put log files. Assumed to be already existing and
+# have write access to graphoid user. (e.g. /vagrant/logs)
+#
+# [*port*]
+# Port the graphoid service listens on for incoming connections. (e.g 11042)
+#
+class graphoid(
+ $base_path,
+ $node_path,
+ $conf_path,
+ $log_dir,
+ $port,
+) {
+
+ $log_file = "${log_dir}/graphoid.log"
+
+ require_package('nodejs')
+ require_package('libcairo2-dev')
+ require_package('libjpeg-dev')
+ require_package('libgif-dev')
+
+ exec { 'npm':
+ # --no-bin-links is required for Windows hosts (unless VBOX runs as
admin, allowing NTFS links)
+ command => 'npm install --no-bin-links',
+ cwd => $base_path,
+ # Without HOME env var, npm install throws this error:
+ # node-gyp requires that the user's home directory is specified in
either
+ # of the environmental variables HOME or USERPROFILE
+ # BUG: We shouldn't hard-code this
+ environment => [ "HOME=/home/vagrant" ],
+ }
+
+ file { $conf_path:
+ ensure => present,
+ content => template('graphoid/config.erb'),
+ }
+
+ # The upstart configuration
+ file { '/etc/init/graphoid.conf':
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => '0444',
+ content => template('graphoid/upstart.erb'),
+ }
+
+ service { 'graphoid':
+ ensure => running,
+ hasstatus => true,
+ hasrestart => true,
+ provider => 'upstart',
+ subscribe => File['/etc/init/graphoid.conf'],
+ }
+}
diff --git a/puppet/modules/graphoid/manifests/install/git.pp
b/puppet/modules/graphoid/manifests/install/git.pp
new file mode 100644
index 0000000..e884203
--- /dev/null
+++ b/puppet/modules/graphoid/manifests/install/git.pp
@@ -0,0 +1,12 @@
+# == Class: graphoid::install::git
+#
+# Provision graphoid by cloning the git repository.
+#
+class graphoid::install::git {
+ include ::graphoid
+
+ git::clone{ 'mediawiki/services/graphoid':
+ directory => $::graphoid::base_path,
+ before => Class['::graphoid'],
+ }
+}
diff --git a/puppet/modules/graphoid/templates/config.erb
b/puppet/modules/graphoid/templates/config.erb
new file mode 100644
index 0000000..5d2799d
--- /dev/null
+++ b/puppet/modules/graphoid/templates/config.erb
@@ -0,0 +1,18 @@
+{
+ "domains": [
+ "localhost",
+ "127.0.0.1",
+ "mediawiki.org",
+ "wikibooks.org",
+ "wikidata.org",
+ "wikimedia.org",
+ "wikimediafoundation.org",
+ "wikinews.org",
+ "wikipedia.org",
+ "wikiquote.org",
+ "wikisource.org",
+ "wikiversity.org",
+ "wikivoyage.org",
+ "wiktionary.org"
+ ]
+}
diff --git a/puppet/modules/graphoid/templates/upstart.erb
b/puppet/modules/graphoid/templates/upstart.erb
new file mode 100644
index 0000000..63adc96
--- /dev/null
+++ b/puppet/modules/graphoid/templates/upstart.erb
@@ -0,0 +1,25 @@
+#####################################################################
+### THIS FILE IS MANAGED BY PUPPET
+#####################################################################
+
+description "Graphoid HTTP service"
+
+start on mediawiki-ready
+stop on runlevel [!2345]
+
+# up ulimit -n a bit
+limit nofile 10000 10000
+
+setuid "www-data"
+setgid "www-data"
+
+env NODE_PATH="<%= @node_path %>"
+env GRAPHOID_PORT="<%= @port %>"
+
+respawn
+
+# wait 60 seconds for a graceful restart before killing the master
+kill timeout 60
+
+chdir "<%= @base_path %>"
+exec /usr/bin/nodejs graphoid.js >> "<%= @log_file %>" 2>&1
diff --git a/puppet/modules/role/manifests/graphoid.pp
b/puppet/modules/role/manifests/graphoid.pp
new file mode 100644
index 0000000..117258a
--- /dev/null
+++ b/puppet/modules/role/manifests/graphoid.pp
@@ -0,0 +1,17 @@
+# == Class: role::graphoid
+# This role installs the graphoid service for server side graph rendering.
+#
+class role::graphoid {
+ require ::graphoid::install::git
+ # use local graphoid renderer
+ mediawiki::settings { 'Graphoid':
+ values => [
+ '$wgGraphImgServiceUrl =
"//localhost:11042?server=%1\$s&title=%2\$s&revid=%3\$s&id=%4\$s.png";',
+ ],
+ }
+
+ vagrant::settings { 'graphoid':
+ forward_ports => { 11042 => 11042 },
+ ram => 2048, # Needed to execute npm install - native
compile uses up too much ram
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/191887
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I16fc80ac0aa459c20e3bd40b03fa786e889542a1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits