Phawikibugs

From Wikitech

Phawikibugs is an instance of the Phabricator Chat Bot running under the wikibugs account on Tool Labs. It uses the pywikibugs user account to communicate with Phabricator.

Starting and stopping

The bot is written as a Phabricator Daemon, which means we need a wrapper to run it on the Grid:

run_phab_bot.sh

#!/bin/bash
# because phabricator uses SIGUSR1 to communicate between child and parent, we need to catch this...

cd /data/project/wikibugs/phabricator

function on_EXIT()
{
  echo Stopping all daemons...
  phabricator/bin/phd stop
  echo Done. Bye-bye!
}

function on_USR1()
{
  echo Received SIGUSR1
}

trap on_USR1 USR1
trap on_EXIT EXIT

echo Starting daemon via PHD!
phabricator/bin/phd launch phabricatorbot `pwd`/phab_config.json
echo Started. Sleep for ALL times!

sleep infinity
#echo Attempting to EXEC daemon
#./libphutil/scripts/daemon/exec/exec_daemon.php PhabricatorBot --load-phutil-library=`pwd`/arcanist/src --load-phutil-library=`pwd`/phabricator/src --verbose -- `pwd`/phab_config.json

The helper script

run_grid.sh

submits the job to the grid:

#!/bin/bash
jstart -once -mem 1G ./run_phab_bot.sh

Configuration

In phab_config.json. Current configuration:

{
  "server" : "irc.freenode.net",
  "port" : 6667,
  "nick" : "phawikibugs",
  "join" : [
    "#mediawiki-feed",
    "#wikimedia-devtools"
  ],
  "handlers" : [
    "PhabricatorBotFeedNotificationHandler"
  ],

  "conduit.uri" : "https://phabricator.wikimedia.org",
  "conduit.user" : "pywikibugs",
  "conduit.cert" : "[redacted]",

  "macro.size" : 48,
  "macro.aspect" : 0.66,

  "notification.channels" : ["#phabot-test"]
}

(I think notification.channels is ignored?)

Status

In development. The basic bot works (as provided by Phabricator), but it needs WMF-specific adjustments. See the task list for details.