calxibe / StorjMonitor

Node.js script for publishing data from local Storj nodes to Storjstat.com
15 stars 14 forks source link

Allow connection to a remote daemon #19

Closed sdesbure closed 6 years ago

sdesbure commented 6 years ago

today in the code (https://github.com/calxibe/StorjMonitor/blob/master/storjMonitor.js#L29), the connection assumes that:

As I'm using oreandawe/strojshare-cli container, the daemon is not on the same host.

Therefore, it would be good to make variables like for token:

var token = "YOUR-TOKEN-HERE"; //api token can be create under "Nodes" -> "API-Key"
var daemon_host= "127.0.0.1"; //where the storj daemon is running
var daemon_port= 45015; //on which port storj daemon is listening
var log = console.log;
...
function fParseNodes() {
    const daemon = dnode.connect(daemon_host, daemon_port);
...

it would also be awesome to have the configuration in a json file (for example config.json):

{
  "token": "YOUR-TOKEN-HERE",
  "daemon_host": "127.0.0.1",
  "daemon_port": 45015
}

then in the code:

var config= require('./config.json')

and then use config.token, config.daemon_host and config.daemon_port.

The interest (for Docker user) is the ability to mount the config (with --volume) and then being able to upgrade easily :)

If you're interested with that, I can make 3 pull requests:

stefanbenten commented 6 years ago

Already merged your first pull request #20 👍 Feel free to implement the other solutions as well. I will rework the install routine in the meantime!

sdesbure commented 6 years ago

I've proposed a pull request for the Dockerfile. I'll see later for the "config.json" part :)