Can't call model from controller using CLI

edited March 2013 in Modules
HI, thanks again for Fuel. I managed to get the cli bootstrapworking. https://github.com/compwright/codeigniter-cli-bootstrap with some modifications to the cron.php for some $server params for the fuel_constants.php file. I have it all running but the model will not load from the controller. I can run the query in the controller function, but can't call the model. I tried $this->load and $CI->load and both are not working. I can get around it without a model but curious of your thoughts. Thanks.

Comments

  • edited 9:34AM
    I use a Mac and have run into problems when trying to use the php command because it maps to the version that comes with OSX which has issues connecting to the database when run via ClI. The solution for me was to map the php command to the installed MAMP version. This thread may help some:
    http://www.getfuelcms.com/forums/discussion/575/automating-database-backups/#Item_14
  • edited 9:34AM
    Hi thanks for the reply. I am running this in Apache on the server. I was using the command line just to test it before I put it on the cron job. So what I found was the first call to the model does not work, so I put the code inside the controller function. After that, I could load the email class and then that same model I could not, suddenly when I go to update the same table I could not call now actually it actually will run the model. Not sure why it would not run in the first call at beginning of the function.

    Nobody online seems to have same issue so thought it must be FUEL since it has some extra things involved.

    It is odd that running from the cron it acts differently. Here is what I have. I am calling it every 3 minutes to test it.
    */3 * * * * root php /home/username/folder_behind_public/cron.php --run=/controller/function

    Now, it prints the session out, but suddenly is running into the auth/login I have added in but that should not get called unless in the header of the view is where I put it. I do not call a view though. So any thoughts on why the command line works but the cron is running into what it seems is a login issue which means someone it is getting to the header file? Make sense? Strange heh. Hope it is simple.

    Thanks
  • edited 9:34AM
    ok, seems running the cron from the actual cpanel user account, not in cron.d fixed that issue of it not running all the way. Also calling the model is working now. So, it must have been a permissions issue. For now seems we are fixed! Using that bootstrap for the cli works well. I added a few variables.

    Keep in mind the --server option is not used.. they must have not updated the documentation. It is internally defaulted to localhost.. but you could hack the cron.php file and adjust it. I added these to cron.php to make FUEL happy.

    $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SCRIPT_FILENAME'] = '/home/username/publicfolder/index.php'; //for us $_SERVER['SERVER_PORT'] = '443'; //HTTPS for us.. port 80 for HTTP

    Hopefully this helps someone.
Sign In or Register to comment.