Skip to content

Run with PM2

Juan Cazala edited this page Dec 12, 2017 · 5 revisions
pm2

Run proxy with pm2 and get load balancing, cluster mode, watch & reload, and live metrics.

First, install pm2 and coin-hive-stratum:

npm i -g pm2 coin-hive-stratum

Then, create a proxy.js file:

const Proxy = require("coin-hive-stratum");
const proxy = new Proxy({
  host: "pool.supportxmr.com",
  port: 3333
});
proxy.listen(8892);

If you want to access your proxy via wss:// you will need to pass a private key and certificate files.

To generate your SSL certificates for your domain or subdomain you can use Certbot.

Certbot will generate the SSL certificates under these paths (where example.com is your domain):

  • key: /etc/letsencrypt/live/example.com/privkey.pem
  • cert: /etc/letsencrypt/live/example.com/fullchain.pem

So you can use them like this:

const Proxy = require("coin-hive-stratum");
const proxy = new Proxy({
  host: "pool.supportxmr.com",
  port: 3333,
  key: require("fs").readFileSync("/etc/letsencrypt/live/example.com/privkey.pem"),
  cert: require("fs").readFileSync("/etc/letsencrypt/live/example.com/fullchain.pem")
});
proxy.listen(8892);

Finally, run the proxy using pm2:

pm2 start proxy.js --name=proxy --log-date-format="YYYY-MM-DD HH:mm"

Now you can monitor your proxy, see the logs and metrics like online miners, submitted shares, etc, using this command:

pm2 monit

To stop the proxy use this:

pm2 stop proxy
Clone this wiki locally