Skip to content

Commit

Permalink
added a better start harness
Browse files Browse the repository at this point in the history
  • Loading branch information
hubchub committed Jun 3, 2023
1 parent 37310db commit 22aabca
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
node_modules
logs
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ npm i

## Usage

You can start every zone on group-0 with

```bash
npm start
```

You can run the script by using the following command.

```bash
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const argv = yargs(hideBin(process.argv))
alias: 'g',
type: 'string',
default: 'group-0',
description: 'Selected group',
description: 'Selected group'
})
.option('zone', {
alias: 'z',
Expand Down
106 changes: 57 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "node start.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.4.0",
"bluebird": "^3.7.2",
"child_process": "^1.0.2",
"config": "^3.3.9",
"path": "^0.12.7",
"quais": "^0.2.2",
"winston": "^3.8.2",
"yargs": "^17.7.2"
},
"devDependencies": {
"standard": "^17.0.0"
"standard": "^17.1.0"
}
}
25 changes: 25 additions & 0 deletions start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { exec } = require('child_process')
const fs = require('fs')
const path = require('path')

const logsDir = path.join(__dirname, 'logs')

if (!fs.existsSync(logsDir)) {
fs.mkdirSync(logsDir)
}

for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
const cmd = `node index.js -g group-0 -z zone-${i}-${j}`
const logStream = fs.createWriteStream(`${logsDir}/zone-${i}-${j}.log`, { flags: 'a' })

const proc = exec(cmd)

proc.stdout.pipe(logStream)
proc.stderr.pipe(logStream)

proc.on('error', (error) => {
console.error(`Error: ${error.message}`)
})
}
}
7 changes: 0 additions & 7 deletions start.sh

This file was deleted.

0 comments on commit 22aabca

Please sign in to comment.