MCPcopy Index your code
hub / github.com/WebThingsIO/webthing-node / runServer

Function runServer

example/platform/index.js:32–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30const BoardThing = require(`./board/${board}`);
31
32function runServer() {
33 const port = process.argv[3] ? Number(process.argv[3]) : 8888;
34 const url = `http://localhost:${port}`;
35
36 log(`Usage:\n\
37${process.argv[0]} ${process.argv[1]} [board] [port]\n\
38Try:\ncurl -H "Accept: application/json" ${url}\
39\n`);
40 const thing = new BoardThing();
41 const server = new WebThingServer(new SingleThing(thing), port);
42 process.on('SIGINT', () => {
43 const cleanup = () => {
44 thing && thing.close();
45 log(`log: board: ${board}: Exit`);
46 process.exit();
47 };
48 server.stop().then(cleanup).catch(cleanup);
49 });
50 server.start().catch(console.error);
51 log(`log: board: ${board}: Started`);
52}
53
54if (module.parent === null) {
55 runServer();

Callers 1

index.jsFile · 0.70

Calls 2

stopMethod · 0.95
startMethod · 0.95

Tested by

no test coverage detected