Async/await let's go!

This commit is contained in:
Zaid Abdulla committed 2019-06-05 00:17:36 -07:00
1 parent 1e6d3acd1b
commit c3501debd5
20 files changed
+2617 -2916

No files matched your search

+8 -6
View File
@@ -27,7 +27,7 @@ function exitWorkerGracefully(): void {
}
function exitWorkerUngracefully(): void {
extensions.killAll(() => {
extensions.killAll().then(() => {
process.exit(1);
});
}
@@ -97,10 +97,8 @@ if (!cluster.worker) {
.catch(exitWorkerUngracefully);
});
db.connect(err => {
if (err) throw err;
cache.connect(err => {
if (err) throw err;
Promise.all([db.connect(), cache.connect()])
.then(() => {
server.start(
SERVICE_PORT,
SERVICE_ADDRESS,
@@ -108,6 +106,10 @@ if (!cluster.worker) {
cwmp.listener,
cwmp.onConnection
);
})
.catch(err => {
setTimeout(() => {
throw err;
});
});
});
}
+2 -2
View File
@@ -59,7 +59,7 @@ function errorToFault(err: Error): Fault {
process.on("uncaughtException", err => {
const fault = errorToFault(err);
jobs.forEach(jobId => {
process.send([jobId, fault]);
process.send([jobId, fault, null]);
});
jobs.clear();
process.disconnect();
@@ -81,7 +81,7 @@ process.on("message", message => {
code: "ext",
message: `No such function '${funcName}' in extension '${fileName}'`
};
process.send([message[0], fault]);
process.send([message[0], fault, null]);
return;
}
+7 -5
View File
@@ -93,11 +93,13 @@ if (!cluster.worker) {
.catch(exitWorkerUngracefully);
});
db.connect(err => {
if (err) throw err;
cache.connect(err => {
if (err) throw err;
Promise.all([db.connect(), cache.connect()])
.then(() => {
server.start(SERVICE_PORT, SERVICE_ADDRESS, ssl, listener);
})
.catch(err => {
setTimeout(() => {
throw err;
});
});
});
}
+8 -6
View File
@@ -27,7 +27,7 @@ function exitWorkerGracefully(): void {
}
function exitWorkerUngracefully(): void {
extensions.killAll(() => {
extensions.killAll().then(() => {
process.exit(1);
});
}
@@ -97,11 +97,13 @@ if (!cluster.worker) {
.catch(exitWorkerUngracefully);
});
db.connect(err => {
if (err) throw err;
cache.connect(err => {
if (err) throw err;
Promise.all([db.connect(), cache.connect()])
.then(() => {
server.start(SERVICE_PORT, SERVICE_ADDRESS, ssl, listener);
})
.catch(err => {
setTimeout(() => {
throw err;
});
});
});
}
+7 -5
View File
@@ -105,11 +105,13 @@ if (!cluster.worker) {
listener(req, res);
};
db2.connect(err => {
if (err) throw err;
cache.connect(err => {
if (err) throw err;
Promise.all([db2.connect(), cache.connect()])
.then(() => {
server.start(SERVICE_PORT, SERVICE_ADDRESS, ssl, _listener);
})
.catch(err => {
setTimeout(() => {
throw err;
});
});
});
}