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,7 +20,6 @@ const attach = (directory) => {
|
|||
});
|
||||
}
|
||||
|
||||
DatabaseConnector.forShared().then(({Account}) => {
|
||||
server.register([HapiWebSocket, Inert], () => {
|
||||
attach('./routes/')
|
||||
|
||||
|
@ -32,6 +31,7 @@ DatabaseConnector.forShared().then(({Account}) => {
|
|||
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,6 +57,7 @@ DatabaseConnector.forShared().then(({Account}) => {
|
|||
ws.send(JSON.stringify({ cmd: "ASSIGNMENTS", payload: assignments}))
|
||||
)
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
disconnect: () => {
|
||||
clearInterval(this.pollInterval);
|
||||
|
@ -73,6 +74,18 @@ DatabaseConnector.forShared().then(({Account}) => {
|
|||
},
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/ping',
|
||||
config: {
|
||||
auth: false,
|
||||
},
|
||||
handler: (request, reply) => {
|
||||
console.log("---> Ping!")
|
||||
reply("pong")
|
||||
},
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/{param*}',
|
||||
|
@ -88,4 +101,3 @@ DatabaseConnector.forShared().then(({Account}) => {
|
|||
console.log('Dashboard running at:', server.info.uri);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue