What should your code do? Almost no code is ever running constantly. See, it would block things, that’s an issue especially with NodeJS which Meteor is built on. Also: If nothing changes no code needs to run.
It seems you are looking for something which returns a result without waiting for a cronjob every x seconds. That should not be an issue.
Also consider: A cron could also run every second for example if it has a really simple task. Not beautiful but works.
Constantly running things does not seem the right thing to do:
I want to access a few Meteor related things in that, particularly have access to the database. And because i use astronomy package for schemas etc, i would prefer if i could run it inside meteor. The added advantage being it would terminate with meteor as well.
Did you also look at observeChanges for example? We need to know what change should call your code. For example some things which can change:
- User input: use Meteor.call()
- External api input: Meteor.call()
- Database change: Meteor.observe()
- Client side change: ReactiveVar()
There are many places where you can hook up your activity.