Steps to test agenda last version (1.0.0):
-
install node modules for express and agenda:
npm i
-
launch a mongoDB (2.6+) e.g., simply use the h3 mongodb
-
launch various test cases:
node src/0_basic_test.js
: Launch a job thatconsole.log
hello every 2 seconds.node src/1_write_file_test.js
: Launch a job that writes "hello" in a file every 5 seconds.node src/2_multi_task_test.js
: Launch two jobs at various frequency and taking various time.node src/3_multi_node_test.js
: Launch the command in several different terminals. Only one node at a time should handle the job.
Use the following to gracefully stop agenda when node stops.
const graceful = () => {
agenda.stop(() => process.exit(0));
};
process.on('SIGTERM', graceful);
process.on('SIGINT' , graceful);
It will prevent jobs to be stucked in a "locked" state.