From 2edcedb1b7cd00e35136a1d3e69c6ce5632cf39f Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Sun, 13 Mar 2022 01:22:45 +0000 Subject: [PATCH] cli: Add basic install support for linux http: Fix so listenAsync defaults to all hosts package: Increment version --- cli.mjs | 24 ++++++++++++++++++++++-- core/http.mjs | 2 +- package.json | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cli.mjs b/cli.mjs index 99d71ce..ebb2043 100644 --- a/cli.mjs +++ b/cli.mjs @@ -82,9 +82,18 @@ if (args[0] === 'checkconfig') { const runner = path.join(process.cwd(), './runner.mjs') fs.stat(runner).catch(function() { + console.log('Creating runner.mjs') return fs.writeFile(runner, basicRunnerTemplate) + }).then(function() { + console.log('Linking local service-core instance') + return util.runCommand('npm', ['link', 'service-core'], null, function(stream) { + console.log(stream.replace('\n', '')) + }) }).then(function() { return Promise.all([ + util.runCommand('npm', ['link', 'service-core'], null, function(stream) { + console.log(stream.replace('\n', '')) + }), fs.readFile(configFile), import('node-windows'), ]) @@ -124,8 +133,19 @@ if (args[0] === 'checkconfig') { svc.install(); }) } else { - console.log('non windows install targets are currently unsupported') - process.exit(2) + const runner = path.join(process.cwd(), './runner.mjs') + + fs.stat(runner).catch(function() { + console.log('Creating runner.mjs') + return fs.writeFile(runner, basicRunnerTemplate) + }).then(function() { + console.log('Linking local service-core instance') + return util.runCommand('npm', ['link', 'service-core'], null, function(stream) { + console.log(stream.replace('\n', '')) + }) + }).then(function() { + console.log('Runner is ready to be added to init.d') + }) } } else if (args[0] === 'uninstall') { if(os.platform() === 'win32') { diff --git a/core/http.mjs b/core/http.mjs index 4602250..2f92050 100644 --- a/core/http.mjs +++ b/core/http.mjs @@ -28,7 +28,7 @@ export default class HttpServer { return new Promise((res, rej) => { server.once('error', rej) - server.listen(port, host || '0.0.0.0', () => { + server.listen(port, host || '::', () => { server.off('error', rej) res() }) diff --git a/package.json b/package.json index c263169..7d3ce02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-core", - "version": "3.0.0-beta.8", + "version": "3.0.0-beta.9", "description": "Core boiler plate code to install node server as windows service", "main": "index.mjs", "scripts": {