Skip to content

start()

app.start([port], [callback])
NameTypeDescription
portnumberOptional. Port to listen on.
callbackFunctionOptional. Called when the server starts.

Returns: http.Server instance.

  1. Explicit argument: app.start(5000)
  2. Config: app.setConfig({ port: 4000 })
  3. Default: 3000
// Default port
app.start();
// Explicit port with callback
app.start(8080, () => console.log("Running on 8080"));
// Environment variable
app.start(process.env.PORT || 3000);

start() automatically enables graceful shutdown — on SIGTERM or SIGINT, the server drains connections and runs cleanup hooks before exiting.

app.onShutdown(async () => {
await db.disconnect();
});
app.start(3000);
// Ctrl+C → connections drain → hooks run → clean exit

Disable or customize via setConfig(). See the full Graceful Shutdown guide for details.