I am trying to build an online code editor for my professor - user writes code and submits code to a nodejs process which then uses nodejs's 'spawn' to start a new process. One of the cases is if a student writes a forever while loop - the new process will consume lot of cpu on the server.
I want to restrict the new processes running in terms of cpu usage and memory usage.
One of the solution I could think was having an external program which checks the cpu and memory usage of new processes and kills them when they cross the threshold.
But I was more keen on an inbuilt solution in nodejs.