Cedric Fung

Mixin me 25566

A Simple Process Monitor

Aug 28, 2020

It’s very common that I start some long running program, and go to other works while waiting for its completion. To make things more efficient, it’s better to be notified as soon as the program exit so that I could start further tasks. I searched and asked around but found no simple solutions, so I make my own utility, pgn.

pgn is a simple process monitor, which sends notification whenever the monitored process exits. The notifications could be delivered to any destinations, but for now it only supports Mixin Messenger, which is my intensive daily app. Unlike other powerful and professional DevOps tools, pgn is very simple to start.

pgn is very portable. Written in Golang, pgn source code is portable in all popular systems, and to make it easier I have included the pre-built binaries for different platforms. Whenever you have the need to get notified for a long running task, you can just download the corresponding pgn binary, make it executable and monitor your task in seconds.

curl -L https://github.com/cedricfung/pgn/raw/master/pgn-linux-x64 -o pgn
chmod +x pgn
./pgn -token ACCESS-TOKEN -run 'ls -l /tmp'

Because of the simplicity of pgn, I used it very often, both on my local computer or the remote servers. Another cool usage is to integrate it with some service manager, e.g. systemd.

[Unit]
Description=Mixin Network Kernel Daemon
After=network.target

[Service]
User=ubuntu
Type=simple
ExecStart=/usr/bin/pgn -token ACCESS-TOKEN -run '/usr/bin/mixin kernel -dir /data/mixin'
Restart=always
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Now whenever the service stops abnormally I would get notified.

References

  1. GitHub: pgn source code

About the Author

Core developer of Mixin Network. Passionate about security and privacy. Strive to formulate elegant code, simple design and friendly machine.

25566 @ Mixin Messenger

https://vec.io