-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (32 loc) · 1.21 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const httpServer = require('http-server');
const path = require('path');
const { launch, connect } = require('hadouken-js-adapter');
const serverParams = {
root: path.resolve('./'),
port: 5555,
open: false,
logLevel: 2,
cache: -1
};
//To Launch the OpenFin Application we need a manifestUrl.
const manifestUrl = `http://localhost:${serverParams.port}/app.json`;
//Start the server server
const server = httpServer.createServer(serverParams);
server.listen(serverParams.port);
(async() => {
try {
console.log(manifestUrl);
//Once the server is running we can launch OpenFin and retrieve the port.
const port = await launch({ manifestUrl });
//We will use the port to connect from Node to determine when OpenFin exists.
const fin = await connect({
uuid: 'server-connection', //Supply an addressable Id for the connection
address: `ws://localhost:${port}`, //Connect to the given port.
nonPersistent: true //We want OpenFin to exit as our application exists.
});
//Once OpenFin exists we shut down the server.
fin.once('disconnected', process.exit);
} catch (err) {
console.error(err);
}
})();