Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
8f3faed11f | |||
95e94b38cc | |||
562ade9763 | |||
5b6b1b0a58 | |||
fa38c2928b | |||
4560d20b04 | |||
fbf2f5958c |
3 changed files with 34 additions and 2 deletions
|
@ -7,6 +7,35 @@ export function run(http, orgPort, ctx) {
|
||||||
let packageInfo = JSON.parse(readFileSync(packagePath))
|
let packageInfo = JSON.parse(readFileSync(packagePath))
|
||||||
|
|
||||||
const server = http.createServer(function (req, res) {
|
const server = http.createServer(function (req, res) {
|
||||||
|
const d1 = new Date().getTime()
|
||||||
|
let finishedRequest = false
|
||||||
|
var done = function () {
|
||||||
|
if (finishedRequest) return
|
||||||
|
finishedRequest = true
|
||||||
|
var requestTime = new Date().getTime() - d1
|
||||||
|
|
||||||
|
let level = 'info'
|
||||||
|
if (res.statusCode >= 400) {
|
||||||
|
level = 'warn'
|
||||||
|
}
|
||||||
|
if (res.statusCode >= 500) {
|
||||||
|
level = 'error'
|
||||||
|
}
|
||||||
|
|
||||||
|
let status = ''
|
||||||
|
if (res.statusCode >= 400) {
|
||||||
|
status = res.statusCode + ' '
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.log[level]({
|
||||||
|
duration: requestTime,
|
||||||
|
status: res.statusCode,
|
||||||
|
}, `<-- ${status}${req.method} ${req.url}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
res.addListener('finish', done);
|
||||||
|
res.addListener('close', done);
|
||||||
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write(JSON.stringify(packageInfo, null, ' '))
|
res.write(JSON.stringify(packageInfo, null, ' '))
|
||||||
res.end()
|
res.end()
|
||||||
|
@ -14,7 +43,7 @@ export function run(http, orgPort, ctx) {
|
||||||
|
|
||||||
let port = orgPort || 4000
|
let port = orgPort || 4000
|
||||||
|
|
||||||
return server.listenAsync(port, '0.0.0.0')
|
return server.listenAsync(port)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
ctx.log.event.info(`Server is listening on ${port} serving package ${packagePath}`)
|
ctx.log.event.info(`Server is listening on ${port} serving package ${packagePath}`)
|
||||||
ctx.log.info(`Server is listening on ${port} serving package ${packagePath}`)
|
ctx.log.info(`Server is listening on ${port} serving package ${packagePath}`)
|
||||||
|
|
|
@ -60,6 +60,9 @@ on_success:
|
||||||
-H "Authorization: token $deploytoken" \
|
-H "Authorization: token $deploytoken" \
|
||||||
-F "attachment=@${CURR_VER}_build-sc.7z" \
|
-F "attachment=@${CURR_VER}_build-sc.7z" \
|
||||||
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases/$RELEASE_ID/assets
|
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases/$RELEASE_ID/assets
|
||||||
|
|
||||||
|
echo "Deplying to production"
|
||||||
|
curl -X POST http://192.168.93.51:8881/update/helloworld
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# on build failure
|
# on build failure
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sc-helloworld",
|
"name": "sc-helloworld",
|
||||||
"version": "2.0.1",
|
"version": "2.0.6",
|
||||||
"description": "Hello World app for service core",
|
"description": "Hello World app for service core",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in a new issue