Version 1.0.2
This commit is contained in:
parent
f32730e0a3
commit
0ad204c8f9
8 changed files with 30 additions and 1028 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -104,3 +104,4 @@ dist
|
||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
*.zip
|
*.zip
|
||||||
|
db.json
|
1
.npmrc
Normal file
1
.npmrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package-lock=false
|
|
@ -1,20 +1,19 @@
|
||||||
import http from 'http'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'fs'
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
export function run(config, db, log, core) {
|
export function run(config, db, log, core, http) {
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
const staticPackage = path.join(__dirname,'../package.json')
|
const staticPackage = path.join(__dirname,'../package.json')
|
||||||
config = JSON.parse(readFileSync(staticPackage))
|
let packageInfo = JSON.parse(readFileSync(staticPackage))
|
||||||
|
|
||||||
const server = http.createServer(function (req, res) {
|
const server = http.createServer(function (req, res) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write(JSON.stringify(config, null, ' '))
|
res.write(JSON.stringify(packageInfo, null, ' '))
|
||||||
res.end()
|
res.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
let port = config.managePort || 4000
|
let port = config.port || 4000
|
||||||
|
|
||||||
server.listen(port, '0.0.0.0', function(err) {
|
server.listen(port, '0.0.0.0', function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
9
config.json
Normal file
9
config.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "service-core-helloworld",
|
||||||
|
"serviceName": "Service-Core HelloWorld App",
|
||||||
|
"description": "Simple Hello world app for service core",
|
||||||
|
"port": 4270,
|
||||||
|
"managePort": 4269,
|
||||||
|
"appRepository": null,
|
||||||
|
"manageRepository": null
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
export function start(config, db, log, core) {
|
export function start(config, db, log, core, http) {
|
||||||
return import('./api/server.mjs').then(function(module) {
|
return import('./api/server.mjs').then(function(module) {
|
||||||
return module.run(config, db, log, core)
|
return module.run(config, db, log, core, http)
|
||||||
})
|
})
|
||||||
}
|
}
|
1003
package-lock.json
generated
1003
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "sc-helloworld",
|
"name": "sc-helloworld",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "Hello World app for service core",
|
"description": "Hello World app for service core",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nodemon --watch api --watch runner.mjs --watch index.mjs runner.mjs",
|
"dev": "nodemon --watch api --watch runner.mjs --watch index.mjs runner.mjs | bunyan",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
"node-static": "^0.7.11"
|
"node-static": "^0.7.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"bunyan-lite": "^1.0.1",
|
||||||
"nodemon": "^2.0.4"
|
"nodemon": "^2.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
runner.mjs
26
runner.mjs
|
@ -1,16 +1,10 @@
|
||||||
import('./index.mjs').then(function(module) {
|
import ServiceCore from 'service-core'
|
||||||
return module.start({}, {}, {
|
import * as server from './index.mjs'
|
||||||
debug: console.log.bind(console),
|
|
||||||
info: console.log.bind(console),
|
const serviceCore = new ServiceCore('sc-manager', import.meta.url)
|
||||||
warn: console.log.bind(console),
|
|
||||||
error: console.error.bind(console),
|
serviceCore.init(server)
|
||||||
fatal: console.error.bind(console),
|
.then(function() {})
|
||||||
event: {
|
.catch(function(err) {
|
||||||
debug: function() {},
|
serviceCore.log.error(err, 'Unknown error starting server')
|
||||||
info: function() {},
|
})
|
||||||
warn: function() {},
|
|
||||||
error: function() {},
|
|
||||||
fatal: function() {},
|
|
||||||
}
|
|
||||||
}, {})
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in a new issue