UPS guard tool

Phala UPS guard

Check: GitHub - l00k/phala-ups-guard

This tools monitors UPS state.
If something is wrong with line power and UPS is switched to battery power supply - tool starts procedure.

Currently Phala uses mining rounds mechanism. It may change in future according to:


  • HID compatible UPS
  • apcupsd package
  • node.js v12+

Additional for remote deployment

  • PHP >= 7.2
  • Composer


There are 2 ways of using this tool

  1. You can copy few files and manually configure everything
  2. or you can use deployer to configure everything


  1. Copy file dist/main.js to <dest>/main.js
  2. Configure nodes and accounts in <dest>/config.json (check configuration section)
  3. Run with node ./main.js

Using deployer

  1. Install dependencies
git clone
cd phala-ups-guard
composer install
npm ci
  1. Configure nodes and accounts in (...)/phala-ups-guard/config.json
  2. Configure host in (...)/phala-ups-guard/hosts.yaml
  3. Deploy - my-ups-guard is hostname from hosts.yaml
    php ./vendor/bin/dep guard:deploy my-ups-guard


Guard configuration (config.json)

You can use config.dist.json as a template.

    "nodes": [
        { "url": "wss://" },
        { "url": "" }
    "accounts": [
            "name": "Miner 01",
            "privateKey": "abc def ghi abc def ghi abc def ghi abc def ghi"
            "name": "Miner 02",
            "privateKey": "abc def ghi abc def ghi abc def ghi abc def ghi"

nodes - list of Phala nodes
nodes[idx].url - node URL - it can WebSocket or RPC HTTP server
accounts - list of managed accounts
accounts[idx].name - account name for logging purpose
accounts[idx].privateKey - mnemonic / private key of account

Hosts for deployment (hosts.yaml)

You can use hosts.dist.yaml as a template.

    port: 22
    user: root
    deploy_path: '/srv/guard'

my-ups-guard - deployer host identifier
<host>.hostname - IP address of your node
<host>.port - self explanatory
<host>.user - root or other user which has access to sudo command (without password - google “visudo nopasswd”)
<host>.deploy_path - directory where all scripts will be placed