Mobrovac has uploaded a new change for review. https://gerrit.wikimedia.org/r/200356
Change subject: Citoid: switch from localsettings.js to config.yaml ...................................................................... Citoid: switch from localsettings.js to config.yaml Citoid has been ported to use the service template/runner combo, which means that as of now the configuration is read from config.yaml. This patch ports the old-style configuration to the new one. Additionally, production logs will be sent to logstash from now on. Change-Id: I25a70352977102ee858b58cbee5825e526f7286c --- M hieradata/common/citoid.yaml M modules/citoid/manifests/init.pp A modules/citoid/templates/config.yaml.erb D modules/citoid/templates/localsettings.js.erb M modules/citoid/templates/upstart-citoid.erb 5 files changed, 71 insertions(+), 59 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/56/200356/1 diff --git a/hieradata/common/citoid.yaml b/hieradata/common/citoid.yaml index 21353cb..eabce7e 100644 --- a/hieradata/common/citoid.yaml +++ b/hieradata/common/citoid.yaml @@ -1,3 +1,4 @@ http_proxy: http://url-downloader.wikimedia.org:8080 zotero_host: zotero.svc.eqiad.wmnet statsd_host: statsd.eqiad.wmnet +logstash_host: logstash1001.eqiad.wmnet diff --git a/modules/citoid/manifests/init.pp b/modules/citoid/manifests/init.pp index 59a1732..169a235 100644 --- a/modules/citoid/manifests/init.pp +++ b/modules/citoid/manifests/init.pp @@ -22,24 +22,24 @@ # [*statsd_port*] # StatsD port. Defaults to 8125. # +# [*logstash_host*] +# GELF logging host. Default: localhost +# +# [*logstash_port*] +# GELF logging port. Default: 12201 +# class citoid( - $port = 1970, - $statsd_port = 8125, - $zotero_port = 1969, - $http_proxy, - $zotero_host, - $statsd_host, + $port = 1970, + $statsd_port = 8125, + $zotero_port = 1969, + $http_proxy = undef, + $zotero_host = 'localhost', + $statsd_host = 'localhost', + $logstash_host = 'localhost', + $logstash_port = 12201, ) { require_package('nodejs') - - $statsd_config = $statsd_host ? { - undef => 'false', - default => ordered_json({ - host => $statsd_host, - port => $statsd_port - }), - } package { 'citoid/deploy': provider => 'trebuchet', @@ -66,9 +66,9 @@ mode => '0755', } - file { '/etc/citoid/localsettings.js': + file { '/etc/citoid/config.yaml': ensure => present, - content => template('citoid/localsettings.js.erb'), + content => template('citoid/config.yaml.erb'), owner => 'root', group => 'root', mode => '0444', diff --git a/modules/citoid/templates/config.yaml.erb b/modules/citoid/templates/config.yaml.erb new file mode 100644 index 0000000..266163c --- /dev/null +++ b/modules/citoid/templates/config.yaml.erb @@ -0,0 +1,53 @@ +# Number of worker processes to spawn. +# Set to 0 to run everything in a single process without clustering. +# Use 'ncpu' to run as many workers as there are CPU units +num_workers: ncpu + +# Log error messages and gracefully restart a worker if v8 reports that it +# uses more heap (note: not RSS) than this many mb. +worker_heap_limit_mb: 300 + +# Logger info +logging: + name: citoid + level: warn + streams: + # Use gelf-stream -> logstash + - type: gelf + host: <%= @logstash_host %> + port: <%= @logstash_port %> + +# Statsd metrics reporter +metrics: + type: txstatsd + host: <%= @statsd_host %> + port: <%= @statsd_port %> + +services: + - name: citoid + # a relative path or the name of an npm package, if different from name + module: ./src/app.js + # optionally, a version constraint of the npm package + # version: ^0.4.0 + # per-service config + conf: + # the port to bind to + port: <%= @port %> + # IP address to bind to, all IPs by default + # interface: localhost # uncomment to only listen on localhost + # allow cross-domain requests to the API (default '*') + cors: '*' + # to disable use: + # cors: false + # to restrict to a particular domain, use: + # cors: restricted.domain.org + # URL of the outbound proxy to use (complete with protocol) + proxy: <%= @http_proxy %> + # User-Agent HTTP header to use for requests + userAgent: WikimediaBot + # URL where to contact Zotero + zoteroInterface: <%= @zotero_host %> + # zotero's server port + zoteroPort: <%= @zotero_port %> + # whether the proxy should be used to contact zotero + zoteroUseProxy: false diff --git a/modules/citoid/templates/localsettings.js.erb b/modules/citoid/templates/localsettings.js.erb deleted file mode 100644 index 84da3a0..0000000 --- a/modules/citoid/templates/localsettings.js.erb +++ /dev/null @@ -1,42 +0,0 @@ -/* - * NOTE: This file is managed by puppet - * - * Citoud configuration file - */ - -var CitoidConfig = { - - // Allow cross-domain requests to the API (default '*') - // Sets Access-Control-Allow-Origin header - // enable: - allowCORS : '*', - // disable: - //allowCORS : false, - // restrict: - //allowCORS : 'some.domain.org', - - // Set proxy for outgoing requests - proxy : '<%= @http_proxy %>', - - // Allow override of port/interface: - citoidPort : <%= @port %>, - citoidInterface : '0.0.0.0', - - // userAgent string for lib/Scraper.js - userAgent : 'WikimediaBot', - - // Settings for Zotero server - zoteroPort : <%= @zotero_port %>, - zoteroInterface : '<%= @zotero_host %>', - // Whether or not the outbound proxy should be used to access Zotero - zoteroUseProxy : false, - - // StatsD endpoint to which metrics should be sent, or false - // to disable metric reporting. - statsd: <%= @statsd_config %>, -}; - -/*Exports*/ -module.exports = CitoidConfig; - - diff --git a/modules/citoid/templates/upstart-citoid.erb b/modules/citoid/templates/upstart-citoid.erb index 3df55d9..344c78d 100644 --- a/modules/citoid/templates/upstart-citoid.erb +++ b/modules/citoid/templates/upstart-citoid.erb @@ -20,4 +20,4 @@ kill timeout 60 chdir /srv/deployment/citoid/deploy -exec /usr/bin/nodejs src/server.js -c /etc/citoid/localsettings.js >> /var/log/citoid/main.log 2>&1 +exec /usr/bin/nodejs src/server.js -c /etc/citoid/config.yaml >> /var/log/citoid/main.log 2>&1 -- To view, visit https://gerrit.wikimedia.org/r/200356 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I25a70352977102ee858b58cbee5825e526f7286c Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Mobrovac <mobro...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits