Skip to content

Commit

Permalink
Merge pull request #684 from dnalborczyk/regression
Browse files Browse the repository at this point in the history
Fix server start handling (callback -> promise)
  • Loading branch information
dherault committed Jun 3, 2019
2 parents 599cfcd + 838809d commit a5d7b60
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/index.js
Expand Up @@ -1070,17 +1070,19 @@ class Offline {
}

// All done, we can listen to incomming requests
_listen() {
return new Promise((resolve, reject) => {
this.server.start(err => {
if (err) return reject(err);
async _listen() {
try {
await this.server.start();
}
catch (e) {
console.error('Unexpected error while starting serverless-offline server:', e);
process.exit(1);
}

this.printBlankLine();
this.serverlessLog(`Offline listening on http${this.options.httpsProtocol ? 's' : ''}://${this.options.host}:${this.options.port}`);
this.printBlankLine();
this.serverlessLog(`Offline listening on http${this.options.httpsProtocol ? 's' : ''}://${this.options.host}:${this.options.port}`);

resolve(this.server);
});
});
return this.server;
}

end() {
Expand Down

0 comments on commit a5d7b60

Please sign in to comment.