faceyspacey.com
faceyspacey.com

Reputation: 2630

Do Meteor servers turn off when not being used? Meteor.setInterval seems to stop eventually

I have Meteor.setInterval set in Meteor.startup, but it seems to stop being called after the site has been inactive for a while. It's as though meteor detects nobody is using the site, and then once somebody uses the site again, Meteor.startup() is called again. But I want the code in Meteor.setInterval to keep running even if nobody is viewing the site. How do I go about that??

Upvotes: 1

Views: 424

Answers (3)

Andrew Mao
Andrew Mao

Reputation: 36910

What you said is exactly right. Meteor.com hosting turns off your site if it isn't being watched and starts it up again the first time someone browses to it after that. Reference:

https://stackoverflow.com/a/19072230/586086

The safest way to keep it running, as of now, would be to use your own server. Hubert OG's suggestion to ping the server periodically also works.

Upvotes: 2

Hubert OG
Hubert OG

Reputation: 19544

Meteor server on itself doesn't stop running. However, the infrastructure on which it runs, can. For example, if your server runs on free plan on Heroku, it will sleep when there are no views. I don't know about Meteor.com, but they may do the same.

Also, Meteor servers can fail, so it's necessary to have a monitoring daemon that will restore the server in such case (forever does the job).

A simple remedy for your problem would be to use an external monitoring tool, like Uptime robot, to ping your app periodically. That way you'll ensure server receives enough visits to run continuously.

Upvotes: 1

cbreezier
cbreezier

Reputation: 1314

As far as I know the server shouldn't stop running - make sure that your code is being executed on the server and not the client.

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup

  });
}

It would be really helpful if you could provide any code snippets so we actually know what you're doing.

Upvotes: 1

Related Questions