add serve command
add listen option and change default port not to interfere with running instance
This commit is contained in:
parent
8c3b09082a
commit
36c62d603f
|
@ -10,6 +10,11 @@ function addGlobal (yargs) {
|
|||
alias: 's',
|
||||
description: 'Vikinja binary to be started before data are populated or Vikunja has to be started manually'
|
||||
})
|
||||
.option('listen', {
|
||||
alias: 'l',
|
||||
description: 'Vikinja API will listen on this network interface',
|
||||
default: ':3455'
|
||||
})
|
||||
.option('workDir', {
|
||||
description: 'directory where Sqlite database will be created if startVikunja was provided, default is folder with Vikunja binary'
|
||||
})
|
||||
|
@ -28,7 +33,7 @@ function addGlobal (yargs) {
|
|||
default: 'demo'
|
||||
})
|
||||
.option('baseUrl', {
|
||||
default: 'http://localhost:3456'
|
||||
default: 'http://localhost:3455'
|
||||
})
|
||||
|
||||
return yargs
|
||||
|
@ -36,7 +41,7 @@ function addGlobal (yargs) {
|
|||
|
||||
async function startVikunjaFromArgv (argv) {
|
||||
if (argv.startVikunja) {
|
||||
return startVikunja(argv.startVikunja, argv.jwtsecret, argv.workDir, argv.deleteDb).then(() => true)
|
||||
return startVikunja(argv.startVikunja, argv.jwtsecret, argv.workDir, argv.deleteDb, argv.listen).then(() => true)
|
||||
}
|
||||
|
||||
return false
|
||||
|
@ -47,8 +52,18 @@ function initClientFromArgv (wasStarted, argv) {
|
|||
}
|
||||
|
||||
yargs(hideBin(process.argv))
|
||||
.command('serve', '', yargs => {
|
||||
addGlobal(yargs)
|
||||
}, async argv => {
|
||||
const wasStarted = await startVikunjaFromArgv(argv)
|
||||
if (wasStarted) {
|
||||
console.log('population done, press any key to quit')
|
||||
await keypress()
|
||||
process.exit()
|
||||
}
|
||||
})
|
||||
.command(
|
||||
'$0 person-as-list',
|
||||
'person-as-list',
|
||||
'will populate Vikunja tasks with persons as lists',
|
||||
yargs => {
|
||||
addGlobal(yargs)
|
||||
|
|
|
@ -3,7 +3,7 @@ import path from 'path'
|
|||
import fs from 'fs-extra'
|
||||
import { spawn } from 'child_process'
|
||||
|
||||
export function startVikunja (bin, jwtSecret, workDir = false, deleteDb = false) {
|
||||
export function startVikunja (bin, jwtSecret, workDir = false, deleteDb = false, serviceInterface = ':3456') {
|
||||
if (!workDir) {
|
||||
workDir = path.dirname(bin)
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ export function startVikunja (bin, jwtSecret, workDir = false, deleteDb = false)
|
|||
{
|
||||
cwd: workDir,
|
||||
env: {
|
||||
VIKUNJA_SERVICE_JWTSECRET: jwtSecret
|
||||
VIKUNJA_SERVICE_JWTSECRET: jwtSecret,
|
||||
VIKUNJA_SERVICE_INTERFACE: serviceInterface
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue