The CLI can be used to for example run one-time only commands or run cronjobs.
If the bootstrap detects that an extra command line argument is given the CLI mode will start.
node server.js superAwesomeCommand
New CLI tasks can be created in the tasks
folder that can be found in your app
folder.
After you import/add your task in the index.js
file you are able to run you task.
It can happen that you need to extend the completed callback.
No problem! With this code you can extend the default completed();
callback:
const NextBootstrap = require('@dpdk/bootstrap');
const bootstrap = new NextBootstrap(__dirname, process.cwd(), nextConfig);
bootstrap.cliCompleted = () => {
// Custom code here
};
bootstrap.init();
To make sure your CLI task won't be running forever the bootstrap protects itself from running longer then 30 seconds.
This timing can be changed by updating the application config:
{
"cli": {
"maxExecutionTimeout": 30
}
}
Last modified | Friday, April 30, 2021, 12:00:21 PM UTC |
Last author | Colin van Eenige |
Commit ID | 4c7a701 |