mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +08:00
Add ping to dashboard, wait to get shared db
This commit is contained in:
parent
3e348252ab
commit
53a2e7e56b
|
@ -20,18 +20,18 @@ const attach = (directory) => {
|
|||
});
|
||||
}
|
||||
|
||||
DatabaseConnector.forShared().then(({Account}) => {
|
||||
server.register([HapiWebSocket, Inert], () => {
|
||||
attach('./routes/')
|
||||
server.register([HapiWebSocket, Inert], () => {
|
||||
attach('./routes/')
|
||||
|
||||
server.route({
|
||||
method: "POST",
|
||||
path: "/accounts",
|
||||
config: {
|
||||
plugins: {
|
||||
websocket: {
|
||||
only: true,
|
||||
connect: (wss, ws) => {
|
||||
server.route({
|
||||
method: "POST",
|
||||
path: "/accounts",
|
||||
config: {
|
||||
plugins: {
|
||||
websocket: {
|
||||
only: true,
|
||||
connect: (wss, ws) => {
|
||||
DatabaseConnector.forShared().then(({Account}) => {
|
||||
Account.findAll().then((accounts) => {
|
||||
accounts.forEach((acct) => {
|
||||
ws.send(JSON.stringify({ cmd: "ACCOUNT", payload: acct }));
|
||||
|
@ -57,35 +57,47 @@ DatabaseConnector.forShared().then(({Account}) => {
|
|||
ws.send(JSON.stringify({ cmd: "ASSIGNMENTS", payload: assignments}))
|
||||
)
|
||||
}, 1000);
|
||||
},
|
||||
disconnect: () => {
|
||||
clearInterval(this.pollInterval);
|
||||
this.observable.dispose();
|
||||
},
|
||||
});
|
||||
},
|
||||
disconnect: () => {
|
||||
clearInterval(this.pollInterval);
|
||||
this.observable.dispose();
|
||||
},
|
||||
},
|
||||
},
|
||||
handler: (request, reply) => {
|
||||
if (request.payload.cmd === "PING") {
|
||||
reply(JSON.stringify({ result: "PONG" }));
|
||||
return;
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
handler: (request, reply) => {
|
||||
if (request.payload.cmd === "PING") {
|
||||
reply(JSON.stringify({ result: "PONG" }));
|
||||
return;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/{param*}',
|
||||
handler: {
|
||||
directory: {
|
||||
path: require('path').join(__dirname, 'public'),
|
||||
},
|
||||
},
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/ping',
|
||||
config: {
|
||||
auth: false,
|
||||
},
|
||||
handler: (request, reply) => {
|
||||
console.log("---> Ping!")
|
||||
reply("pong")
|
||||
},
|
||||
});
|
||||
|
||||
server.start((startErr) => {
|
||||
if (startErr) { throw startErr; }
|
||||
console.log('Dashboard running at:', server.info.uri);
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/{param*}',
|
||||
handler: {
|
||||
directory: {
|
||||
path: require('path').join(__dirname, 'public'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
server.start((startErr) => {
|
||||
if (startErr) { throw startErr; }
|
||||
console.log('Dashboard running at:', server.info.uri);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue