Skip to content

Commit d05505c

Browse files
committed
adding /shutdown endpoint to all JS REST SUTs
1 parent a8c00e4 commit d05505c

16 files changed

Lines changed: 28966 additions & 11649 deletions

File tree

js_npm/rest/cyclotron/em/app-driver.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
const dbHandler = require("./db-handler");
2-
3-
const http = require("http");
4-
const {AddressInfo} = require("net");
52
const mongoose = require('mongoose');
63

74
const em = require("evomaster-client-js");

js_npm/rest/cyclotron/package-lock.json

Lines changed: 12417 additions & 5399 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js_npm/rest/cyclotron/src/server.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,15 @@ const app = require("./app");
55
var port = app.get('port');
66
app.listen(port, function(){
77
console.log('Cyclotron running on port %d', port);
8-
});
8+
});
9+
10+
11+
/*
12+
Added to be able to collect coverage with C8. See:
13+
https://github.com/bcoe/c8/issues/166
14+
*/
15+
//setTimeout(()=> process.exit(0), 10000)
16+
// process.on("SIGINT", () =>{console.log("SIGINT"); process.exit(0)})
17+
// process.on("SIGTERM", () =>{console.log("SIGTERM"); process.exit(0)})
18+
// process.on("SIGUSR1", () =>{console.log("SIGUSR1"); process.exit(0)})
19+
app.post("/shutdown", () => process.exit(0))

js_npm/rest/disease-sh-api/src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (dotenv.error) {
1313
}
1414

1515
// SERVER PORT
16-
const port = process.env.SERVER_PORT || 3000;
16+
const port = process.env.PORT || process.env.SERVER_PORT || 3000;
1717

1818
// REDIS CONFIGURATION
1919
config.redis.host = process.env.REDIS_HOST || (process.env.DOCKER ? 'redis' : 'localhost');

js_npm/rest/disease-sh-api/src/serverStart.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ const config = require('../src/config/index')
55

66
const port = config.port
77
app.listen(port, () => logger.info(`Your app is listening on port ${port}`));
8+
9+
10+
/*
11+
Added to be able to collect coverage with C8. See:
12+
https://github.com/bcoe/c8/issues/166
13+
*/
14+
//setTimeout(()=> process.exit(0), 10000)
15+
// process.on("SIGINT", () =>{console.log("SIGINT"); process.exit(0)})
16+
// process.on("SIGTERM", () =>{console.log("SIGTERM"); process.exit(0)})
17+
// process.on("SIGUSR1", () =>{console.log("SIGUSR1"); process.exit(0)})
18+
app.post("/shutdown", () => process.exit(0))

js_npm/rest/ncs/src/server.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@ const port = process.env.PORT || 8080;
55
app.listen(port, () => {
66
console.log("Started RESTful API on port " + port);
77
});
8+
9+
10+
11+
/*
12+
Added to be able to collect coverage with C8. See:
13+
https://github.com/bcoe/c8/issues/166
14+
*/
15+
//setTimeout(()=> process.exit(0), 10000)
16+
// process.on("SIGINT", () =>{console.log("SIGINT"); process.exit(0)})
17+
// process.on("SIGTERM", () =>{console.log("SIGTERM"); process.exit(0)})
18+
// process.on("SIGUSR1", () =>{console.log("SIGUSR1"); process.exit(0)})
19+
app.post("/shutdown", () => process.exit(0))

js_npm/rest/realworld-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "[![Build Status](https://travis-ci.org/anishkny/node-express-realworld-example-app.svg?branch=master)](https://travis-ci.org/anishkny/node-express-realworld-example-app)",
55
"main": "src/index.js",
66
"scripts": {
7-
"build": "rimraf build && tsc",
7+
"build": "rimraf build && tsc && babel swagger.json -d build --copy-files",
88
"em:run": "node instrumented/em/em-main.js",
99
"em:build": "npm run build && rimraf instrumented & babel build -d instrumented --copy-files && babel em -d instrumented/em --copy-files && babel swagger.json -d instrumented --copy-files && babel em -d build/em --copy-files",
1010
"start": "node src/index.js",

js_npm/rest/realworld-app/src/main.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,25 @@ async function bootstrap() {
1919
//Man: there exists some problems with auto-generated swagger, i.e., lack of parameter info
2020
SwaggerModule.setup('/docs', app, document);
2121

22+
/*
23+
Added to be able to collect coverage with C8. See:
24+
https://github.com/bcoe/c8/issues/166
25+
*/
26+
//setTimeout(()=> process.exit(0), 10000)
27+
// process.on("SIGINT", () =>{console.log("SIGINT"); process.exit(0)})
28+
// process.on("SIGTERM", () =>{console.log("SIGTERM"); process.exit(0)})
29+
// process.on("SIGUSR1", () =>{console.log("SIGUSR1"); process.exit(0)})
30+
app.getHttpAdapter().post("/shutdown", () => process.exit(0))
31+
32+
2233
app.use('/swagger.json', (req, res) => {
2334
res.status(200);
2435
res.json(require('../swagger.json'));
2536
});
2637

38+
const port = process.env.PORT || 3000;
39+
2740
//mysql is employed, docker run --name mysql_db -e MYSQL_ROOT_PASSWORD=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test -e MYSQL_DATABASE=test -p 3306:3306 -d mysql:5.7.22
28-
await app.listen(3000);
41+
await app.listen(port);
2942
}
3043
bootstrap();

js_npm/rest/scs/src/server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ const port = process.env.PORT || 8080;
55
app.listen(port, () => {
66
console.log("Started RESTful API on port " + port);
77
});
8+
9+
10+
/*
11+
Added to be able to collect coverage with C8. See:
12+
https://github.com/bcoe/c8/issues/166
13+
*/
14+
//setTimeout(()=> process.exit(0), 10000)
15+
// process.on("SIGINT", () =>{console.log("SIGINT"); process.exit(0)})
16+
// process.on("SIGTERM", () =>{console.log("SIGTERM"); process.exit(0)})
17+
// process.on("SIGUSR1", () =>{console.log("SIGUSR1"); process.exit(0)})
18+
app.post("/shutdown", () => process.exit(0))

js_npm/rest/spacex-api/em/app-driver.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const dbHandler = require("./db-handler");
22
const em = require("evomaster-client-js");
3+
const http = require("http");
4+
const app = require("../src/app");
35

46

57
class AppController extends em.SutController {
@@ -44,7 +46,8 @@ class AppController extends em.SutController {
4446

4547
await dbHandler.startDb();
4648

47-
this.server = require("./appAPIs");
49+
const app = require("../src/app");
50+
const server = http.createServer(app.callback());
4851
this.server.listen(0, "localhost", () => {
4952
this.port = this.server.address().port;
5053
resolve("http://localhost:" + this.port);

0 commit comments

Comments
 (0)