WebSub Part I: Watchtower
Excited by the possibilities offered with the new MicroSub Draft Standard, I thought I’d install Aaron Parecki’s Aperture Microsub Server and see what the present status of the protocol was like. I hope to write a reader for my own use, and to do that, I need to have a reference point. The installation process was enjoyable, if a little bewildering, but, as Aaron makes explicitly clear, This is alpha level software. Do not use.
This journal is written partly as a description of that process, and partly as a first brush at documentation. I’m sorry, therefore, if it seems a little muddled at times. It is the result of several different attempts at installation, and leaves out a lot of the handwringing.
I recommend that before starting the process, the user should have created two (sub)domains and created standalone letsencrypt certificates for both. I refer to them here as watchtower.
and aperture.example.com
Watchtower
Aperture relies on a WebSub-style API to watch the Subscriptions for changes. This is currently provided by Aaron’s Watchtower which will need to be installed first.
System Requirements
Installation
Clone the repository to a serving-location on your server. The composer requirements are installed with the standard composer install
command. Then prepare a mysql database with a suitable user.
$ mysql -u root -p
mariaDB> CREATE DATABASE watchtower;
mariaDB> CREATE USER 'watchtoweruser'@'localhost' IDENTIFIED BY 'watchtowerpass';
mariaDB> GRANT ALL PRIVILEGES ON watchtower.* to 'watchtoweruser'@'localhost';
mariaDB> FLUSH PRIVILEGES;
mariaDB> exit;
Configuration
In the repo under scripts
is schema.sql
. This needs to be imported into the watchtower database to initialise the tables.
$ mysql --user="watchtoweruser" --database="watchtower" --password="watchtowerpass" < ./schema.sql
It is also necessary to create the primary user at this time, using the address of your soon-to-be Aperture server and an api token of your own devising.
$ mysql -u watchtower -p
mariaDB> use watchtower;
mariaDB> INSERT INTO users (url, token, created_at) values ('https://aperture.example.org', 'myapitoken', '2018-02-09 09:00:00');
mariaBD> exit;
Finally, you need to set the configuration up. Copy libs/config.example.php to libs/config.php, and then edit the values. There’s not a lot to configure.
<?php
class Config {
public static $base_url = 'https://watchtower.example.com';
public static $dbHost = '127.0.0.1';
public static $dbName = 'watchtoweruser';
public static $dbUsername = 'watchtower';
public static $dbPassword = 'watchtowerpass';
public static $beanstalkServer = '127.0.0.1';
public static $beanstalkPort = 11300;
}
Watchtower as a Service
One the database is populated, Watchtower needs to be run as a persistent service, on linux boxes you can use a systemd service (from a helpful tip by Eddie Hinckle)
[Unit]
Description=watchtower worker
[Service]
WorkingDirectory=/path/to/watchtower/scripts
User=www-data
ExecStart=/path/to/php watchtower.php
Restart=always
[Install]
WantedBy=multi-user.target
Lastly, a cronjob needs to be added to execute the file scripts/cron.php
on a regular basis. This is the main element of watchtower’s functionality.
*/5 * * * * /usr/bin/php /path/to/watchtower/scripts/cron.php
That’s all, folks! Thing is, this was the easy part of the process. My next post will detail getting Aperture itself up and running.
- I just have more succesful outcomes with nginx than the alternatives. Your mileage may vary. [return]