How to use the restart function from pm2
Find comprehensive JavaScript pm2.restart code examples handpicked from public code repositorys.
GitHub: ryanlelek/Raneto
92 93 94 95 96 97 98 99 100 101
.command('restart') .description('Restart Raneto Service') .action(() => { pm2.connect(() => { // (error, proc) pm2.restart('raneto', (error) => { if (error) { console.log(`Raneto could not be restarted: ${error.msg}`); process.exit(1); } else {
449
0
0
146 147 148 149 150 151 152 153 154 155
console.info(m); console.error(m); // Process restart return new Promise((resolve, reject) => { pm2.restart(this.pm_id, (err) => { if (err) { console.error(`Process ${this.name} - restart failed. ${err.message || err}`); reject(err); return;
8
16
5
+ 29 other calls in file
GitHub: Hookyhook/Poker-Bot
801 802 803 804 805 806 807 808 809 810
await game.startinteraction.followUp({ embeds: [embed], components: [], }); //The bot is completely restarted via the pm2 api to reset all vars pm2.restart("pokerbot", (err) => { if (err) throw err; console.log("Bot restarted successfully"); });
0
1
0
GitHub: iconjone/StockBot
21 22 23 24 25 26 27 28 29 30
setTimeout(() => { pm2.connect(() => { setInterval(function shouldRestart() { if (restart) { bot.send("Restarting due to hanged process"); pm2.restart("index"); } else { restart = true; } }, 60000);
1
0
2
+ 116 other calls in file
GitHub: AGUickers/AGUickers_Bot
3926 3927 3928 3929 3930 3931 3932 3933 3934 3935
bot.sendMessage(chatId, messages.messages.update_error); } else { console.log(stdout); child.exec("chmod 777 ./update.sh"); bot.sendMessage(chatId, messages.messages.update_done); pm2.restart("./app.js"); } } ); break;
0
1
1
+ 67 other calls in file
245 246 247 248 249 250 251 252 253 254
} } //Função responsavel por reiniciar a instancia caso desconect function onCrashBotMakeThat() { pm2.restart('sofie-hermes') } function writeReasonCrashJson(reason){ let object_reason = {
0
0
1
17 18 19 20 21 22 23 24 25 26 27
}); }; const restartAsync = (process) => { return new Promise((resolve, reject) => { pm2.restart(process, (err, proc) => { if (err) reject(err); resolve(proc); }); });
0
0
1
pm2.restart is the most popular function in pm2 (219 examples)