20after4 has uploaded a new change for review.

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

Change subject: Configuration for Aphlict
......................................................................

Configuration for Aphlict

Aphlict is the node.js-based websocket server that powers the
Phabricator real-time notification service refs T112765, T765

Bug: T112765
Change-Id: I182e2e28e38514cb03e8ac79192fe165ad6e6ee0
---
A modules/phabricator/files/logrotate_aphlict
A modules/phabricator/manifests/aphlict.pp
A modules/phabricator/templates/aphlict-config.json.erb
A modules/phabricator/templates/aphlict-upstart.conf.erb
A modules/phabricator/templates/aphlict.service.erb
5 files changed, 161 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/37/313937/1

diff --git a/modules/phabricator/files/logrotate_aphlict 
b/modules/phabricator/files/logrotate_aphlict
new file mode 100644
index 0000000..99b5672
--- /dev/null
+++ b/modules/phabricator/files/logrotate_aphlict
@@ -0,0 +1,8 @@
+/var/log/aphlict {
+    daily
+    compress
+    delaycompress
+    missingok
+    notifempty
+    rotate 7
+}
diff --git a/modules/phabricator/manifests/aphlict.pp 
b/modules/phabricator/manifests/aphlict.pp
new file mode 100644
index 0000000..aa4d971
--- /dev/null
+++ b/modules/phabricator/manifests/aphlict.pp
@@ -0,0 +1,98 @@
+# == Class: phabricator::aphlict
+# Aphlict is the phabricator real-time notification relay service.
+# Docs: https://secure.phabricator.com/book/phabricator/article/notifications/
+class phabricator::aphlict(
+    $user   = 'aphlict',
+    $group  = 'aphlict',
+) {
+    # packages
+    require_package('nodejs')
+
+    # paths
+    $basedir = $phabricator::phabdir
+    $phabdir = "${basedir}/phabricator/"
+    $aphlict_dir = "${phabdir}/support/aphlict/server"
+    $node_modules = "${aphlict_dir}/node_modules"
+    $aphlict_conf = "${basedir}/aphlict/config.json"
+    $aphlict_cmd = "${phabdir}/bin/aphlict start --config ${aphlict_conf}"
+
+    # Ordering
+    Package['nodejs'] -> File[$aphlict_conf] ~> Service['aphlict']
+    File['/var/run/aphlict/'] -> File['/var/log/aphlict/'] -> 
Service['aphlict']
+    User[$user] -> Service['aphlict']
+    File[$node_modules] ~> Service['aphlict']
+
+    # Defines
+    file { $node_modules:
+        ensure => 'link',
+        target => "${basedir}/aphlict/node_modules",
+    }
+
+    file { $aphlict_conf:
+        ensure  => 'present',
+        content => template('phabricator/aphlict-config.json.erb'),
+        owner   => $user,
+        group   => $group,
+        mode    => '0644',
+    }
+
+    if $::initsystem == 'upstart' {
+        # upstart init conf file
+        $init_file = '/etc/init/aphlict.conf'
+        $init_source = 'aphlict-upstart.conf.erb'
+    } else {
+        # systemd service unit
+        $init_file = '/etc/systemd/system/aphlict.service'
+        $init_source = 'aphlict.service.erb'
+    }
+
+    file { '/etc/init.d/aphlict':
+        ensure => 'link',
+        target => "${phabdir}/bin/aphlict",
+    }
+
+    file { $init_file:
+        content => template("phabricator/${init_source}"),
+        mode    => '0644',
+        owner   => 'root',
+        group   => 'root',
+    }
+
+    service { 'aphlict':
+        ensure     => running,
+        provider   => $::initsystem,
+        hasrestart => true,
+    }
+
+    file { '/var/run/aphlict/':
+        ensure => 'directory',
+        owner  => $user,
+        group  => $group,
+    }
+
+    file { '/var/log/aphlict/':
+        ensure => 'directory',
+        owner  => $user,
+        group  => $group,
+    }
+
+    logrotate::conf { 'aphlict':
+        ensure  => 'present',
+        source  => 'puppet:///modules/phabricator/logrotate_aphlict',
+        require => File['/var/log/aphlict/']
+    }
+
+    # accounts
+    group { $group:
+        ensure => 'present',
+        system => true,
+    }
+
+    user { $user:
+        gid    => 'aphlict',
+        shell  => '/bin/false',
+        home   => '/var/run/aphlict',
+        system => true,
+    }
+
+}
diff --git a/modules/phabricator/templates/aphlict-config.json.erb 
b/modules/phabricator/templates/aphlict-config.json.erb
new file mode 100644
index 0000000..56b6556
--- /dev/null
+++ b/modules/phabricator/templates/aphlict-config.json.erb
@@ -0,0 +1,26 @@
+{
+  "servers": [
+    {
+      "type": "client",
+      "port": 22280,
+      "listen": "0.0.0.0",
+      "ssl.key": null,
+      "ssl.cert": null,
+      "ssl.chain": null
+    },
+    {
+      "type": "admin",
+      "port": 22281,
+      "listen": "127.0.0.1",
+      "ssl.key": null,
+      "ssl.cert": null,
+      "ssl.chain": null
+    }
+  ],
+  "logs": [
+    {
+      "path": "/var/log/aphlict/aphlict.log"
+    }
+  ],
+  "pidfile": "/var/run/aphlict/aphlict.pid"
+}
diff --git a/modules/phabricator/templates/aphlict-upstart.conf.erb 
b/modules/phabricator/templates/aphlict-upstart.conf.erb
new file mode 100644
index 0000000..6d9a3b1
--- /dev/null
+++ b/modules/phabricator/templates/aphlict-upstart.conf.erb
@@ -0,0 +1,16 @@
+# aphlict - Phabricator notification server
+#
+# Routes real-time notifications to websocket clients
+
+description    "Phabricator notification websocket server"
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+respawn
+respawn limit 10 5
+umask 022
+
+expect stop
+
+exec <%= @aphlict_cmd %>
diff --git a/modules/phabricator/templates/aphlict.service.erb 
b/modules/phabricator/templates/aphlict.service.erb
new file mode 100644
index 0000000..e46ce4a
--- /dev/null
+++ b/modules/phabricator/templates/aphlict.service.erb
@@ -0,0 +1,13 @@
+[Unit]
+Description=Aphlict - Phabricator notification service
+After=network.target auditd.service
+
+[Service]
+ExecStart=<%= @aphlict_cmd %>
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
+Alias=aphlict.service

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I182e2e28e38514cb03e8ac79192fe165ad6e6ee0
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: 20after4 <mmod...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to