From 3b38eeec2ba831e109ad26ed9a00a79ff30d089e Mon Sep 17 00:00:00 2001 From: Nakul Manchanda Date: Tue, 7 Jul 2020 00:54:40 -0400 Subject: [PATCH] fix npm start,manual start z/os script,health chk Signed-off-by: Nakul Manchanda --- package.json | 2 +- server/app.js | 17 +++++++++++++---- start-sample.sh | 10 ++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 start-sample.sh diff --git a/package.json b/package.json index c483f51..f3f2782 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "start": "node server/app.js", + "start": "node server/app.js --service sample-node-api --port 8080 --key sslcert/server.key --cert sslcert/server.cert", "build": "npm run clean && cp -r server dist/server && cp -r bin dist/bin && cp *.yml dist && cp *.json dist && cp *.js dist && rimraf dist/package-lock.json", "clean": "rimraf dist && mkdirp dist" }, diff --git a/server/app.js b/server/app.js index 93438d5..bb0bdf9 100644 --- a/server/app.js +++ b/server/app.js @@ -130,13 +130,22 @@ app.use(cors()); const routes = require('./routes/index.route'); app.get('/', (req, res) => res.send('Hello World!')); +app.get('/health', (req, res) => { + const healthcheck = { + uptime: process.uptime(), + message: 'OK', + timestamp: Date.now() + }; + res.send(JSON.stringify(healthcheck)); +}); app.use(routes); -// const httpServer = http.createServer(app); +const httpServer = http.createServer(app); const httpsServer = https.createServer(credentials, app); -// httpServer.listen(HTTP_PORT); -httpsServer.listen(config.port); -console.log(`server listening at port ${config.port}`); +httpServer.listen(config.port); +httpsServer.listen(config.port+1); +console.log(`http server listening at port ${config.port}`); +console.log(`https server listening at port ${config.port + 1}`); module.exports = { app }; \ No newline at end of file diff --git a/start-sample.sh b/start-sample.sh new file mode 100644 index 0000000..c075fce --- /dev/null +++ b/start-sample.sh @@ -0,0 +1,10 @@ +## start locally +node server/app.js --service sample-node-api --port 8080 --key sslcert/server.key --cert sslcert/server.cert -v + +## start on z/os uss +KEYSTORE_DIRECTORY=/u/nakul/zowe/keystore +KEYSTORE_ALIAS=localhost +KEYSTORE_PREFIX="${KEYSTORE_DIRECTORY}/${KEYSTORE_ALIAS}/${KEYSTORE_ALIAS}.keystore" +KEYSTORE_KEY=${KEYSTORE_PREFIX}.key +KEYSTORE_CERTIFICATE=${KEYSTORE_PREFIX}.cer-ebcdic +node server/app.js --service sample-node-api --port 19000 --key ${KEYSTORE_KEY} --cert ${KEYSTORE_CERTIFICATE} -v \ No newline at end of file