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',
|
alias: 's',
|
||||||
description: 'Vikinja binary to be started before data are populated or Vikunja has to be started manually'
|
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', {
|
.option('workDir', {
|
||||||
description: 'directory where Sqlite database will be created if startVikunja was provided, default is folder with Vikunja binary'
|
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'
|
default: 'demo'
|
||||||
})
|
})
|
||||||
.option('baseUrl', {
|
.option('baseUrl', {
|
||||||
default: 'http://localhost:3456'
|
default: 'http://localhost:3455'
|
||||||
})
|
})
|
||||||
|
|
||||||
return yargs
|
return yargs
|
||||||
|
@ -36,7 +41,7 @@ function addGlobal (yargs) {
|
||||||
|
|
||||||
async function startVikunjaFromArgv (argv) {
|
async function startVikunjaFromArgv (argv) {
|
||||||
if (argv.startVikunja) {
|
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
|
return false
|
||||||
|
@ -47,8 +52,18 @@ function initClientFromArgv (wasStarted, argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
yargs(hideBin(process.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(
|
.command(
|
||||||
'$0 person-as-list',
|
'person-as-list',
|
||||||
'will populate Vikunja tasks with persons as lists',
|
'will populate Vikunja tasks with persons as lists',
|
||||||
yargs => {
|
yargs => {
|
||||||
addGlobal(yargs)
|
addGlobal(yargs)
|
||||||
|
|
|
@ -3,7 +3,7 @@ import path from 'path'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import { spawn } from 'child_process'
|
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) {
|
if (!workDir) {
|
||||||
workDir = path.dirname(bin)
|
workDir = path.dirname(bin)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ export function startVikunja (bin, jwtSecret, workDir = false, deleteDb = false)
|
||||||
{
|
{
|
||||||
cwd: workDir,
|
cwd: workDir,
|
||||||
env: {
|
env: {
|
||||||
VIKUNJA_SERVICE_JWTSECRET: jwtSecret
|
VIKUNJA_SERVICE_JWTSECRET: jwtSecret,
|
||||||
|
VIKUNJA_SERVICE_INTERFACE: serviceInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user