Day 2 operations

Options for running Butler.

Running Butler

How to start and keep Butler running varies depending on whether you are using Docker or a native Node.js approach.

Running under Docker

Starting Butler is easy.
First configure the docker-compose.yml file as needed, then start the Docker container in interactive mode (with output sent to the screen). This is useful to ensure everything works as intended when first setting up Butler.

docker-compose up

Once Butler has been verified to work as intended, hit ctrl-c to stop it.
Then start Butler in deameon (background) mode:

docker-compose up -d

From here on the Docker enviromment will make sure Butler is always running, including restarting it if it for some reason stops.

Running as native Node.js app

Starting Butler as a Node.js task is easy too:

cd \node\butler\src
node butler.js

It is of course also possible to put those commands in a command file (.bat on Windows, .sh etc on other platforms) file and execute that file instead.

Windows services & process monitors

As Butler is the kind of service that (probably) should always be running on a server, it makes sense using a Node.js process monitor to keep it alive (if running Butler as a Docker container you get this for free).

On Windows you can use the excellent Nssm tool to make Butler run as a Windows Service, with all the benefits that follow (can be monitored using operations tools, automatic restarts etc).

If running Butler as a Node.js app on Linux, PM2 and Forever are two process monitors that both have been successfully tested with Butler.

One caveat with these is that it can be hard to start them (and thus Butler) when a Windows server is rebooted. PM2 can be used to solve this challenge in a nice way, more info in this blog post. On the other hand - just using Nssm is probably the easiest option for Windows.

Monitoring Butler

Once Butler is running it’s a good idea to also monitor it. Otherwise you stand the risk of not getting notified if Butler for some reason misbehaves.

Butler will log data on its memory usage to InfluxDB if

  1. The config file’s Butler.uptimeMonitor.enable and Butler.uptimeMonitor.storeInInfluxdb.enable properties are both set to true.
  2. The remaining InfluxDB properties of the config file are correctly configured.

Assuming everything is correctly set up, you can then create a Grafana dashboard showing Butler’s memory use over time. You can also set up alerts in Grafana if so desired, with notifications going to most IM tools and email.

A Grafana dashboard can look like this. Note that one of the available metrics (external) is not used in this particular dashboard. It’s still logged to InfluxDB though.

alt text

There is a sample Grafana dashboard in Butler’s GitHub repo.

Last modified 2020-11-16: v4.2.0 RC1 (0a8214e)