Skip to content

Commit cc775b9

Browse files
committed
Server: added command line arguments support. Now you can rewrite config parameters with command line arguments
1 parent dbd99e8 commit cc775b9

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

DOCKER.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sudo docker run --rm --network=host -d olton/mina_monitor_server:latest -journal
99
### Set Mina Monitor Server parameters
1010
Begin from 1.1.5, you can redefine config parameters with command line arguments:
1111
```shell
12-
node server/index -publicKey B62q... -price:currency usd -alertToDiscord ["FAIL"]
12+
node server/index -publicKey B62q... -price:currency usd -alertToDiscord FAIL,EXEC,STATUS
1313
```
1414
This command overwrite three config parameters:
1515
```json
@@ -18,7 +18,7 @@ This command overwrite three config parameters:
1818
"price": {
1919
"currency": "usd"
2020
},
21-
"alertToDiscord": ["FAIL"]
21+
"alertToDiscord": ["FAIL", "EXEC", "STATUS"]
2222
}
2323
```
2424

LICENSE

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
The MIT License (MIT)
32

43
Copyright (c) 2021 Serhii Pimenov.

server/helpers/arguments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const updateConfigFromArguments = (c) => {
2828
v = Number(v)
2929
} else if (['true', 'false'].includes(v.toLowerCase())) {
3030
v = v.toLowerCase() === 'true'
31-
} else if (v.includes("[")) {
31+
} else if (v.includes("[") || v.includes(",")) {
3232
v = v.replace(/[\[\]"'`]/gi, "").split(",")
3333
}
3434

server/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ const {processJournal} = require("./modules/journal")
1919
const {updateConfigFromArguments} = require("./helpers/arguments");
2020

2121
// const __dirname = dirname(fileURLToPath(import.meta.url))
22+
const configPathLinux = "/etc/minamon/config.json"
2223
const configPath = path.resolve(__dirname, 'config.json')
2324

2425
if (!fs.existsSync(configPath)) {
2526
throw new Error("Config file not exist!")
2627
}
2728

28-
const config = updateConfigFromArguments(JSON.parse(fs.readFileSync(configPath, 'utf-8')))
29+
const readConfig = (path) => updateConfigFromArguments(JSON.parse(fs.readFileSync(path, 'utf-8')))
30+
31+
const config = readConfig(process.platform === 'linux' && fs.existsSync(configPathLinux) ? configPathLinux : configPath)
2932
const [SERVER_HOST, SERVER_PORT] = config.host.split(":")
3033

34+
console.log(config)
35+
3136
/* Create log dir */
3237
const logDir = path.resolve(__dirname, "logs")
3338
if (!fs.existsSync(logDir)) fs.mkdirSync(logDir)

server/minamon.service

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ StartLimitBurst=3
88
Type=simple
99
Restart=always
1010
RestartSec=15
11-
ExecStart=/usr/bin/node /home/user-name/mina-monitor/index
12-
ExecStop=/usr/bin/pkill -9 -f "node mina-monitor/index"
11+
ExecStart=/usr/bin/node /home/user/minamon/index
12+
ExecStop=/usr/bin/pkill -9 -f "node minamon/index"
1313

1414
[Install]
1515
WantedBy=multi-user.target

server/modules/node.js

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ query ($publicKey: String!) {
7373
stateHash
7474
unknown
7575
}
76+
timing {
77+
vesting_period
78+
vesting_increment
79+
initial_mininum_balance
80+
cliff_time
81+
cliff_amount
82+
}
7683
}
7784
}
7885
`;

0 commit comments

Comments
 (0)