Skip to content

Instantly share code, notes, and snippets.

@x-labz
Last active November 4, 2022 11:57
Show Gist options
  • Save x-labz/6f6f8c5e0ba236ccd3d7bc248a017815 to your computer and use it in GitHub Desktop.
Save x-labz/6f6f8c5e0ba236ccd3d7bc248a017815 to your computer and use it in GitHub Desktop.
task-keepalive
function keepAliveTask(task) {
while (true) {
try {
log('starting task:', task.name)
task()
}
catch (error) {
log('task crashed:', task.name, error )
}
}
}
// starting the service tasks
keepAliveTask( task1 )
keepAliveTask( task2 )
keepAliveTask( task3 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment