Skip to content

Commit

Permalink
add DEFAULT_CONFIG_FILENAME
Browse files Browse the repository at this point in the history
  • Loading branch information
dutu committed Oct 6, 2023
1 parent c156711 commit eb24d2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Replace `YOUR_API_TOKEN` and `YOUR_CHAT_ID` with the actual values you obtained
* To run the bisq-watcher, use:

```shell
npm start bisq-watcher
npm start
```

## Notification Testing
Expand Down Expand Up @@ -192,14 +192,14 @@ If you need to monitor two Bisq instances on the same computer, follow these ste
* Start the second watcher:

```shell
CONFIG_NAME=bisq-watcher2 npm start
npm start -- --config bisq-watcher2.config.mjs
```


* To start the second watcher with PM2:

```shell
pm2 start bisq-watcher2
pm2 start bisq-watcher2.config.mjs
```

# Contributions
Expand Down
6 changes: 3 additions & 3 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const appName = process.env.APP_NAME || 'bisq-watcher'
const configFileName = process.env.APP_NAME || 'bisq-watcher.config.mjs'

module.exports = {
apps: [{
name: appName,
name: configFileName,
script: 'server/app.mjs',
args: `--config ${appName}.config.mjs`,
args: `--config ${configFileName}`,
}],
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"monitoring-tool"
],
"scripts": {
"start": "node server/app.mjs --config bisq-watcher.config.mjs"
"start": "node server/app.mjs"
},
"dependencies": {
"ajv": "^8.12.0",
Expand Down
6 changes: 4 additions & 2 deletions server/validateConfiguration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import rules from './rules/rules.mjs'
import rulesSchema from './rules/rules.schema.mjs'
import { pathToFileURL } from 'url'

const DEFAULT_CONFIG_FILENAME = 'bisq-watcher.config.mjs'

const ajvInstance = new ajv({ strictTypes: false })

/**
Expand Down Expand Up @@ -59,7 +61,7 @@ export class AppConfigError extends Error {
* // Run the script with: node script.js --name example
* findConfigFilePath() // Returns undefined
*
* @returns {string|undefined} The path to the config file or undefined if not specified.
* @returns {string} The path to the config file or undefined if not specified. Defaults to DEFAULT_CONFIG_FILENAME
*/
const findConfigFilePath = function findConfigFilePath() {
// Check if CONFIG_NAME environment variable is set
Expand All @@ -77,7 +79,7 @@ const findConfigFilePath = function findConfigFilePath() {
}
}

return configFilePath
return configFilePath || DEFAULT_CONFIG_FILENAME
}

/**
Expand Down

0 comments on commit eb24d2c

Please sign in to comment.