Add shutdownIntervalDays argument

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2024-06-04 20:42:04 +07:00
parent 32a7c1513a
commit 857dfd33c2
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307
2 changed files with 15 additions and 7 deletions

View File

@ -27,11 +27,13 @@ And then run:
To configure it with custom parameters append optional program arguments in the following order:
Arguments: `port cleanupTorFiles intervalSec useLocalhostForP2P network`
Arguments: `port cleanupTorFiles intervalSec shutdownIntervalDays useLocalhostForP2P network`
If `shutdownIntervalDays` is 0 the app will not be shut down. Otherwise, it's the number of days for shutting down (run
script need to ensure the node gets started again).
Values: `Integer 0|1 Integer 0|1 BTC_MAINNET|BTC_TESTNET|BTC_REGTEST`
Values: `Integer 0|1 Integer Integer 0|1 BTC_MAINNET|BTC_TESTNET|BTC_REGTEST`
Example for localhost, regtest on port 8080: `8080 0 10 1 BTC_REGTEST`
Example for localhost, regtest on port 8080: `8080 0 10 5 1 BTC_REGTEST`
Example for production node with cleanupTorFiles=true: `80 1`

View File

@ -52,12 +52,13 @@ public class InventoryMonitorMain {
private static boolean stopped;
// Example prog args:
// 8080 0 10 1 BTC_REGTEST
// 8080 0 10 5 1 BTC_REGTEST
public static void main(String[] args) {
// Default values
int port = 80;
boolean cleanupTorFiles = false;
int intervalSec = 120;
int shutdownIntervalDays = 5;
boolean useLocalhostForP2P = false;
BaseCurrencyNetwork network = BaseCurrencyNetwork.BTC_MAINNET;
@ -75,10 +76,13 @@ public class InventoryMonitorMain {
intervalSec = Integer.parseInt(args[2]);
}
if (args.length > 3) {
useLocalhostForP2P = args[3].equals("1");
shutdownIntervalDays = Integer.parseInt(args[3]);
}
if (args.length > 4) {
network = BaseCurrencyNetwork.valueOf(args[4]);
useLocalhostForP2P = args[4].equals("1");
}
if (args.length > 5) {
network = BaseCurrencyNetwork.valueOf(args[5]);
}
String appName = "bisq-inventory-monitor-" + network;
@ -93,7 +97,9 @@ public class InventoryMonitorMain {
inventoryMonitor.start(port);
// We shut down after 5 days to avoid potential memory leak issue.
// The start script will restart the app.
UserThread.runAfter(InventoryMonitorMain::shutDown, TimeUnit.DAYS.toSeconds(5));
if (shutdownIntervalDays > 0) {
UserThread.runAfter(InventoryMonitorMain::shutDown, TimeUnit.DAYS.toSeconds(shutdownIntervalDays));
}
keepRunning();
}