[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Scap: Add config and tell Scap to deploy it

2016-09-01 Thread Mobrovac (Code Review)
Mobrovac has submitted this change and it was merged.

Change subject: Scap: Add config and tell Scap to deploy it
..


Scap: Add config and tell Scap to deploy it

Bug: T144542
Change-Id: I9778f5fd0bd9b2481a88fc4dc07daedac1b42bb3
---
A scap/config-files.yaml
M scap/scap.cfg
A scap/templates/config.yaml.j2
A scap/vars.yaml
4 files changed, 121 insertions(+), 0 deletions(-)

Approvals:
  Mobrovac: Verified; Looks good to me, approved



diff --git a/scap/config-files.yaml b/scap/config-files.yaml
new file mode 100644
index 000..5b176e5
--- /dev/null
+++ b/scap/config-files.yaml
@@ -0,0 +1,5 @@
+---
+/etc/mathoid/config.yaml:
+  template: config.yaml.j2
+  erb_syntax: True
+  remote_vars: /etc/mathoid/config-vars.yaml
diff --git a/scap/scap.cfg b/scap/scap.cfg
index 7c1f58d..3ce993a 100644
--- a/scap/scap.cfg
+++ b/scap/scap.cfg
@@ -10,6 +10,7 @@
 service_name: mathoid
 service_port: 10042
 lock_file: /tmp/scap.mathoid.lock
+config_deploy: True
 
 [wmnet]
 git_server: tin.eqiad.wmnet
diff --git a/scap/templates/config.yaml.j2 b/scap/templates/config.yaml.j2
new file mode 100644
index 000..fc57367
--- /dev/null
+++ b/scap/templates/config.yaml.j2
@@ -0,0 +1,95 @@
+# 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: <%= num_workers %>
+
+# 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: <%= worker_heap_limit_mb %>
+
+# The maximum interval in ms that can pass between two beat messages
+# sent by each worker to the master before it is killed
+worker_heartbeat_timeout: <%= worker_heartbeat_timeout %>
+
+# Logger info
+logging:
+  level: warn
+  name: <%= log_name %>
+  streams: 
+- host: <%= logstash_host %>
+  port: <%= logstash_port %>
+  type: gelf
+- level: info
+  path: <%= log_file %>
+  type: file
+
+# Statsd metrics reporter
+metrics: 
+  name: <%= metrics_name %>
+  host: <%= metrics_host %>
+  port: <%= metrics_port %>
+  type: statsd
+
+services:
+  - name: <%= name %>
+# a relative path or the name of an npm package, if different from name
+module: ./src/app.js
+# per-service config
+conf:
+  port: <%= port %>
+  # interface: localhost # uncomment to only listen on localhost
+  # more per-service config settings
+  # the location of the spec, defaults to spec.yaml if not specified
+  # spec: ./spec.template.yaml
+  # 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
+  # content for the CSP headers
+  # csp: false  # uncomment this line to disable sending them
+  # URL of the outbound proxy to use (complete with protocol)
+  proxy: <%= proxy %>
+  # the list of domains for which not to use the proxy defined above
+  # no_proxy_list:
+  #   - domain1.com
+  #   - domain2.org
+  # the list of incoming request headers that can be logged; if left empty,
+  # the following headers are allowed: cache-control, content-length,
+  # content-type, if-match, user-agent, x-request-id
+  # log_header_whitelist:
+  #   - cache-control
+  #   - content-length
+  #   - content-type
+  #   - if-match
+  #   - user-agent
+  #   - x-request-id
+  # list of enabled renders
+  svg: true
+  img: true
+  png: true
+  speech: false
+  texvcinfo: true
+  speech_on: false
+  no_check: true
+  dpi: 180
+  svgo: false
+  # the user agent to use when issuing requests
+  # user_agent: service-template-node
+  # the template used for contacting the MW API
+  mwapi_req:
+method: post
+uri: <%= mwapi_uri %>
+headers:
+  host: '{{request.params.domain}}'
+  user-agent: '{{user-agent}}'
+body: '{{ default(request.query, {}) }}'
+  # the template used for contacting RESTBase
+  restbase_req:
+method: '{{request.method}}'
+uri: <%= restbase_uri %>/{{domain}}/v1/{+path}
+query: '{{ default(request.query, {}) }}'
+headers: '{{request.headers}}'
+body: '{{request.body}}'
+
diff --git a/scap/vars.yaml b/scap/vars.yaml
new file mode 100644
index 000..1170d48
--- /dev/null
+++ b/scap/vars.yaml
@@ -0,0 +1,20 @@
+# general
+num_workers: 0
+worker_heap_limit_mb: 250
+worker_heartbeat_timeout: 7500
+# log-related variables
+log_name: mathoid
+logstash_host: localhost
+logstash_port: 12201
+log_file: /tmp/mathoid.log
+# metrics
+metrics_name: mathoid
+metrics_host: localhost
+metrics_port: 8252
+# service
+name: mathoid
+port: 10042
+proxy: 
+mwapi_uri: http://localhost/w/api.php
+restbase_uri: http://localho

[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Scap: Add config and tell Scap to deploy it

2016-09-01 Thread Mobrovac (Code Review)
Mobrovac has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/308071

Change subject: Scap: Add config and tell Scap to deploy it
..

Scap: Add config and tell Scap to deploy it

Bug: T144542
Change-Id: I9778f5fd0bd9b2481a88fc4dc07daedac1b42bb3
---
A scap/config-files.yaml
M scap/scap.cfg
A scap/templates/config.yaml.j2
A scap/vars.yaml
4 files changed, 121 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mathoid/deploy 
refs/changes/71/308071/1

diff --git a/scap/config-files.yaml b/scap/config-files.yaml
new file mode 100644
index 000..19b60f6
--- /dev/null
+++ b/scap/config-files.yaml
@@ -0,0 +1,5 @@
+---
+/etc/mathoid/config.yaml:
+  template: config.yaml.y2
+  erb_syntax: True
+  remote_vars: /etc/mathoid/config-vars.yaml
diff --git a/scap/scap.cfg b/scap/scap.cfg
index 7c1f58d..3ce993a 100644
--- a/scap/scap.cfg
+++ b/scap/scap.cfg
@@ -10,6 +10,7 @@
 service_name: mathoid
 service_port: 10042
 lock_file: /tmp/scap.mathoid.lock
+config_deploy: True
 
 [wmnet]
 git_server: tin.eqiad.wmnet
diff --git a/scap/templates/config.yaml.j2 b/scap/templates/config.yaml.j2
new file mode 100644
index 000..fc57367
--- /dev/null
+++ b/scap/templates/config.yaml.j2
@@ -0,0 +1,95 @@
+# 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: <%= num_workers %>
+
+# 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: <%= worker_heap_limit_mb %>
+
+# The maximum interval in ms that can pass between two beat messages
+# sent by each worker to the master before it is killed
+worker_heartbeat_timeout: <%= worker_heartbeat_timeout %>
+
+# Logger info
+logging:
+  level: warn
+  name: <%= log_name %>
+  streams: 
+- host: <%= logstash_host %>
+  port: <%= logstash_port %>
+  type: gelf
+- level: info
+  path: <%= log_file %>
+  type: file
+
+# Statsd metrics reporter
+metrics: 
+  name: <%= metrics_name %>
+  host: <%= metrics_host %>
+  port: <%= metrics_port %>
+  type: statsd
+
+services:
+  - name: <%= name %>
+# a relative path or the name of an npm package, if different from name
+module: ./src/app.js
+# per-service config
+conf:
+  port: <%= port %>
+  # interface: localhost # uncomment to only listen on localhost
+  # more per-service config settings
+  # the location of the spec, defaults to spec.yaml if not specified
+  # spec: ./spec.template.yaml
+  # 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
+  # content for the CSP headers
+  # csp: false  # uncomment this line to disable sending them
+  # URL of the outbound proxy to use (complete with protocol)
+  proxy: <%= proxy %>
+  # the list of domains for which not to use the proxy defined above
+  # no_proxy_list:
+  #   - domain1.com
+  #   - domain2.org
+  # the list of incoming request headers that can be logged; if left empty,
+  # the following headers are allowed: cache-control, content-length,
+  # content-type, if-match, user-agent, x-request-id
+  # log_header_whitelist:
+  #   - cache-control
+  #   - content-length
+  #   - content-type
+  #   - if-match
+  #   - user-agent
+  #   - x-request-id
+  # list of enabled renders
+  svg: true
+  img: true
+  png: true
+  speech: false
+  texvcinfo: true
+  speech_on: false
+  no_check: true
+  dpi: 180
+  svgo: false
+  # the user agent to use when issuing requests
+  # user_agent: service-template-node
+  # the template used for contacting the MW API
+  mwapi_req:
+method: post
+uri: <%= mwapi_uri %>
+headers:
+  host: '{{request.params.domain}}'
+  user-agent: '{{user-agent}}'
+body: '{{ default(request.query, {}) }}'
+  # the template used for contacting RESTBase
+  restbase_req:
+method: '{{request.method}}'
+uri: <%= restbase_uri %>/{{domain}}/v1/{+path}
+query: '{{ default(request.query, {}) }}'
+headers: '{{request.headers}}'
+body: '{{request.body}}'
+
diff --git a/scap/vars.yaml b/scap/vars.yaml
new file mode 100644
index 000..1170d48
--- /dev/null
+++ b/scap/vars.yaml
@@ -0,0 +1,20 @@
+# general
+num_workers: 0
+worker_heap_limit_mb: 250
+worker_heartbeat_timeout: 7500
+# log-related variables
+log_name: mathoid
+logstash_host: localhost
+logstash_port: 12201
+log_file: /tmp/mathoid.log
+# metrics
+metrics_name: mathoid
+metrics_host: localhost
+metrics_port: 8252
+# service
+name: mathoid
+port: 10042
+