我需要在我的 nodejs 应用程序中定期执行一些任务。如果它是固定期限,那么它工作正常。但在我的情况下,周期应该动态变化。下面是我的代码,它没有按我的预期工作。这里 cronjob 没有更新我更改期间的期间。
var period = 1;
var CronJob = require('cron').CronJob;
new CronJob('*/' + period + ' * * * * *', function () {
console.log("some task");
}, null, true, "Indian/Mauritius");
new CronJob('*/5 * * * * *', function () {
period = period * 2;
console.log("updating cronjob period");
}, null, true, "Indian/Mauritius");
Run Code Online (Sandbox Code Playgroud) 我需要在某些条件下停止我的nodejs应用程序.所以我使用了process.exit()方法.我正在用PM2运行我的应用程序.但PM2在停止时会重新启动应用程序.那么有没有可能在PM2中禁用重启.
我需要调试我的nodejs 进程的100% cpu 使用率。我发现node --prof myapp.js非常有帮助。现在我有另一个应用程序将分叉子进程,我需要调试该子进程。这就是我分叉流程的方式。
require('child_process').fork("childfile.js", ["arg1","arg2], {silent: true});
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,是否可以分析子进程,那么我如何传递“--prof”选项。