How do you automatically restart a node.script once it stops

ygreq's icon

Is there a possibility to automatically restart a node.script once it stops?

Thank you!!

ygreq's icon

Anyone?

ygreq's icon

I don't know how to intercept messages from node.script to Max Console. For example I banging the script to get the price of a coin at the Binance Node patch I am building. And whenever the server stops working I get this message:

node.script: Node script not running, can't handle message getPriceOf

I would like to use this message to trigger a start message to the node.script.

Do you know how to get messages to Max Console that start with node.script:

Thank you for looking into it.

ygreq's icon

I am actually trying to build an efficient watchdog solution. For know the only solution I got is to just send a start message every 5 seconds. Which is not an efficient solution at all.

ygreq's icon

Hey, RAJA! The console object is a good idea. Why did you delete your message?

Anyway thank you for your help! A great find indeed!

Sam Tarakajian's icon

Hey ygreq,

Check out the second outlet of node.script. You should get a "terminated" message out of this outlet whenever the process is no longer running. You can use this to restart the process, but yeah, be careful about infinite loops. The node.script object also has a "running" attribute that you can watch with getattr, that you can use in a similar way. Hope that helps,

-S