CLI mode - Controller constructor works fine but not method |
[eluser]bapobap[/eluser]
Hi all, I'm having trouble with CLI mode and I'm hoping someone can help. For some reason, the test method below doesn't get executed when I have a CRON task setup as: Code: /usr/local/bin/php /home/website/public_html/index.php cli_test_c test If I put something in the constructor, it works, however the method itself doesn't get called and I can't figure out why. I've got uri_protocol set to CLI in config.php. I tried phpinfo to see if everything was getting set properly and it seemed to be, phpinfo had the correct stuff in the $_SERVER['argv'] array but I'm not sure what CI uses to route in CLI mode. Does anyone have any ideas?! Pulling my hair out! Code: <?php
[eluser]bubbafoley[/eluser]
There is a bug in 2.0.0 where you have to be working the same directory as index.php for the CLI to work. It's fixed in yet-to-be-released 2.0.1: https://bitbucket.org/ellislab/codeignit...f456598028
[eluser]bapobap[/eluser]
[quote author="bubbafoley" date="1300146600"]There is a bug in 2.0.0 where you have to be working the same directory as index.php for the CLI to work. It's fixed in yet-to-be-released 2.0.1: https://bitbucket.org/ellislab/codeignit...f456598028[/quote] Thanks bubbafoley. I tried that quick patch but unfortunately, it hasn't fixed my problem. I've taken a look at the CI core files and it appears it does use $_SERVER['argv'] in CLI mode, so I'm not sure what's going wrong. If I call the method from the constructor manually using $this->test() it works fine. Any other ideas?!
[eluser]bapobap[/eluser]
Finally figured it out! My code was trying to ask the cron task to login as it didn't have a valid session (you need to be logged in for the entire site) and was trying to redirect the cron task to the login page! I'm such an idiot. Thanks for your help bubbafoley! |
Welcome Guest, Not a member yet? Register Sign In |