How to crash my Node app on purpose?

后端 未结 4 605
无人及你
无人及你 2020-12-30 20:27

I\'ve been working on a deployment work flow with Dokku and Docker and now I want to take care of continuity of my app (along the lines of Forever). To test it, I need a way

4条回答
  •  无人及你
    2020-12-30 20:58

    Three things come to my mind:

    • You could just call process.exit. This for sure brings your application to a state where it needs to be restarted.
    • The other option might be to run an endless loop, something such as while (true) {}. This should make Node.js use 100% of your CPU, and hence the application should be restarted as well (although this, of course, means that you / someone has to watch your application).
    • Create a module in C that crashes by e.g. trying to access a random place in memory. I have no such module at hand, but I'm pretty sure that it should be quite easy for someone with C skills to write such a module.

提交回复
热议问题