setInterval restart server delay

Hello all, I’m using setInterval to do stuff on the server.
Pretty short actions, but… I also console.log to the terminal.

The thing is, because of the setInterval, it takes time until the server restarts. I can see that, because the logging starts before Meteor prints out “Server restarted”.

It really slows down the reloading of my app, and slows down my development.

How can I make the restarting happen before the setIntervals?

What I tried:

  • All setInterval’s are inside a Meteor.startup block, doesn’t help.
  • Searching the forums for setInterval restart server, there’s nothing about it.
  • ???
  • Profit.

I never used setInterval on server side, there are various cron packages, like Synced cron.

SyncedCron.add({
  name: 'hitbox feed',
  schedule: function(parser) {
    // parser is a later.parse object
    return parser.text('every 2 minutes');
  },
  job: function() {
    getHitboxStreams();
    return true;
  }
});
1 Like