Good job on a great-looking module here! I can't quite get it to work for my use case, though... I have all of my environments on the same server, and I run cron via Drush like this: php /usr/bin/drush/drush.php --root=/path/to/mysite.com/www/ --uri=http://www.mysite.com cron and php /usr/bin/drush/drush.php --root=/path/to/mysite.com/dev/ --uri=http://dev.mysite.com cron. Thus, though they're operating on two completely separate code bases (and databases), they're both identified by Cron Control as 127.0.0.1. Is there a way to distinguish by domain name rather than IP address? Or is there another way we could get this to work in our use case? Thanks!

Comments

mkalkbrenner’s picture

Could you please describe more detailed what exactly does not work?

Due to the fact that you are using two different databases, it should work perfectly well if you p.e. turn ON the cron of the system module on 127.0.0.1 for http://www.mysite.com and OFF on 127.0.0.1 for http://dev.mysite.com. Otherwise there's possibly a bug in cron control ...

BTW turning the ip addresses into domain names makes no sense. In a multi site setup you can share tables and the configuration of cron control. In a clustered environment you have one domain for different servers.

traviscarden’s picture

Maybe I should back up and ask whether I'm trying to use Cron Control for what it's designed for or not. I have a web site with several environments: Development, Staging, and Production. I want to keep them all identical (except for new development), but there are certain cron hooks I don't want running anywhere but Production—namely, things like Ping module or XML Sitemap Engines contacting outside services. I thought Cron Control might enable me to specify on which environments I ran which hooks. But I was hoping to put the configuration into a Feature module or something that could be shared by all the environments and decide at time of cron run what to run instead of manually maintaining distinctions. Does that make sense?

mkalkbrenner’s picture

Yes it makes sense to not run some hook_cron implementations in a dev or staging environment.

Are you able to bind your environments to different IP addresses like 127.0.0.1, 127.0.0.2 and 127.0.0.3?

traviscarden’s picture

Well, they're all on the same server, so I don't know that I can do anything to differentiate based on IP address at all—the same cron daemon runs them all via Drush. The only way I can think of to differentiate is by the domain name as specified in the Drush command: php /usr/bin/drush/drush.php --root=/path/to/mysite.com/www/ --uri=http://www.mysite.com cron. So if I understand the situation well, either Cron Control is the wrong module choice for this use case, or I could make this a feature request to allow distinction by domain name rather than IP address. What do you think?

mkalkbrenner’s picture

It's the right module regarding it's features. But maybe not in your special case.

From my point of view it's still not a good approach to have three different configurations in each of your three installations.

Nevertheless you could simply add hosts entries on your server to achieve what you need:

127.0.0.1 www.mysite.com
127.0.0.2 staging.mysite.com
127.0.0.3 dev.mysite.com

On a linux box, add them to /etc/hosts. On windows it's somewhere in the system folders.

traviscarden’s picture

Status: Active » Closed (fixed)

Very good. Thank you for your help!