start()
Signature
Section titled “Signature”app.start([port], [callback])Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
port | number | Optional. Port to listen on. |
callback | Function | Optional. Called when the server starts. |
Returns: http.Server instance.
Port Precedence
Section titled “Port Precedence”- Explicit argument:
app.start(5000) - Config:
app.setConfig({ port: 4000 }) - Default:
3000
Examples
Section titled “Examples”// Default portapp.start();
// Explicit port with callbackapp.start(8080, () => console.log("Running on 8080"));
// Environment variableapp.start(process.env.PORT || 3000);Graceful Shutdown
Section titled “Graceful Shutdown”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 exitDisable or customize via setConfig(). See the full Graceful Shutdown guide for details.