Running the server
June 2, 2024 ยท View on GitHub
The run instruction starts the server.
The configuration file
is specified using the config option.
Any other option will be merged as a configuration property.
$ autoserver run --config=autoserver.config.yml --protocols.http.port=5001
Node.js
When fired from Node.js, autoserver.run() returns a promise, which resolves
with:
If an error occurred, the promise will be rejected with an exception object.
import { run } from 'autoserver'
try {
const { protocols, serverinfo } = await run()
console.log('Servers started at:', protocols)
console.log('Process id', serverinfo.process.id)
} catch (error) {
console.log('Could not start servers:', error)
}
Stopping the server
To stop the server, you can:
- using the
PID, fireprocess.kill(pid)from Node.js - using the
PID, firekill $pidfrom the console - type
CTRL-Cif the server is running in the console foreground. Type this only once, not twice, or the server will not properly shut down.
The PID (process ID) is available:
- using the
serverinfo.process.idparameter. This parameter is also available in the resolved value of the promise returned byautoserver.run(). - printed on the console by the
console log provider