-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a secure route that calls the artisan cron:run command #21
Comments
I like your idea and this will make Cron easier to use. It is difficult to generate a token and write it into a config file. You need write access and writing a value to a specific position in a file is no fun with php. If Cron is used with an external service, in most cases you can only define the url you call, not the post values or other things (like headers). So we can only use the url with all get parameters to secure the call. I would prefer to use the route only. Because a generated long route definition could potentially crash with other definitions, I would recommend to let the Cron user define this route in the Cron config file. Maybe we can offer a command which generates a long route string (but does not write it into the config file). So the steps to use Cron would be to install it, activate the route and/or command function in the config file and maybe set the route string for Cron. Now you can define the jobs in the |
I was hoping there was some kind of Laravel function to hook into, which takes care of it. I haven't found it if it exists though.
Yes, Drupal does it with a GET parameter, here's an example from their docs: If we were to use a GET parameter (which I prefer), then a configuration file could be provided with a |
I found some functions which help to edit files: Illuminate/Filesystem/Filesystem.php. But there is no function to edit a config value. So we have to write this ;) Laravel does the same with the application key and I like the idea that you can configure everything with commands. When Drupal use a GET parameter, we should use it, too. A route like To simplify Cron we could append the following to the /*
|--------------------------------------------------------------------------
| Cron job definitions
|--------------------------------------------------------------------------
*/
Event::listen('cron.collectJobs', function($rundate) {
// TODO add Cron jobs with Cron::add here
}); After that the Cron user needs only to add his jobs and configure crontab (or external service). What do you think? |
I was thinking of something more high-level. I think it's doable to create a command that produces a config file with default values and a generated cron key. Not sure if that's really worth the hassle though. The
I don't think that would be a good idea. App developers should be skilled enough to copy such code from the README and paste it where they need it.
They can already put this in their crontab: * * * * * php /path/to/laravel/artisan cron:run The above also has the advantage of not being limited by a webserver context (think |
Okay, I have to do the following:
Did I forget anything? |
I guess that's about it. Of course the cron key in the default config file should be empty, and a code comment with a short explanation of the use of |
The features were added. Please test it (the route url is |
Very nice, it works! Thx for implementing! Hope you can tag a new release soon :) |
Follow-up of #20
The package should provide a route that calls
Artisan::call('cron:run')
. This should of course have some form of protection to prevent anyone from accessing the URL inadvertently, potentially causing issues. So my idea is that there should be an automatically generated security token, which will be saved to a configuration file.A few things to consider (hey, I don't have all the answers):
php artisan config:publish liebig/cron
?The text was updated successfully, but these errors were encountered: