ookamiiixd / baileys-api

Simple WhatsApp REST API with multiple device support
MIT License
434 stars 332 forks source link

Running Exit : Cleanup Before Star #96

Closed mdestafadilah closed 1 year ago

mdestafadilah commented 2 years ago
failed to activate
> start > node . Running cleanup before exit. > start > node . Running cleanup before exit. > start > node . Running cleanup before exit. > start > node . Running cleanup before exit.
mdestafadilah commented 2 years ago

you must change this line

nodeCleanup(cleanup)
nodeCleanup({
    ctrl_C: "{^C}",
    uncaughtException: "Uh oh. Look what happened:"
});
mdestafadilah commented 2 years ago
async function exitHandler(evtOrExitCodeOrError: number | string | Error) {
  try {
    // await async code here
    // Optionally: Handle evtOrExitCodeOrError here
  } catch (e) {
    console.error('EXIT HANDLER ERROR', e);
  }

  process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError);
}

[
  'beforeExit', 'uncaughtException', 'unhandledRejection', 
  'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 
  'SIGABRT','SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 
  'SIGUSR2', 'SIGTERM', 
].forEach(evt => process.on(evt, exitHandler));

i have't tested... source: https://stackoverflow.com/a/63223515

ookamiiixd commented 1 year ago

Should be fixed in the latest version