j-guyon / commandschedulerbundle Goto Github PK
View Code? Open in Web Editor NEWSymfony bundle that will allow you to schedule all your commands just like unix crontab, with a nice admin panel
Symfony bundle that will allow you to schedule all your commands just like unix crontab, with a nice admin panel
Hello,
Is there a way to enable logging via Monolog in this bundle rather than to file? In our current system we use Monolog to log to syslog, it would be great if this bundle would support logging via Monolog too (or have an independent way of writing in syslog).
Thanks!
when I run php app/console scheduler:execute --dump
it says
Start : Dump all scheduled command Immediately execution asked for : app:mycommand
but no log-file is generated and I think my command is not executed (I don't the any results - it should generate a file)
But when I type my command
php app/console app:mycommand
it works without any problems.
I set the log_path and even created the logFile.log which I also use as name for the output log (myFile.log).
Any help for debugging appreciated. Thanks.
Hello there,
Regarding the logs created by the scheduler, is there a mechanism to enable logs rotation ?
ping @anacicconi
Thanks
Nicolas
In documentation we have this
# This default value disables timeout checking (see monitoring), set to a numeric value (seconds) to enable it
lock_timeout: false
If I got it right if change value of lock_timeout I would like CommandChedulerBundle to stop commands that are running at least, given time(in seconds). What is happening? Clearly nothing, I have idea that it is used to email to people when script timeouts, and then someone should manually stop it. I would like also option to automatically stop, because I'm using automatically cron-flow. Thanks
After install i always get this error
Is there a reason why we are specifying the column names in the mapping ?
I'm personally using Symfony's default naming strategy for Doctrine (with is lowercase underscore), and the bundle creates this only one full uppercased table.
Since we can't override the mapping, shouldn't we remove the column names so Doctrine can fallback on the configured strategy ?
Great bundle by the way !
I have installed CommandSchedularBundle via composer. I have got the all the screens. I have created two schedulers. One for every 10 mins and the other for every 5 mins. The sehedulers runs only when I run this command php bin/console scheduler:execute
When I go to monitor page it always gives empty array [ ] which means everything ok.
Am I missing any configurations ? Or should I want to enable any PHP extensions ?
It is not possible to use twig 2 with this bundle, please add |~2.0 for the twig version constraint.
With the default config of the bundle ->scalarNode('log_path')->defaultValue('var\logs')->end()
I want to execute php bin/console scheduler:execute
and the result: var/logs\ not found or not writable. You should override log_path
in your config.yml.
Is this an OS path configuration problem? When I change var\logs
by var/logs
it works. Maybe this default configuration is for Windows OS specifically.
I'm also facing another error. I have installed the bundle step by step just like the documentation says, then in route /command-scheduler/detail/new
the form for creating a new task the fields seems to be not focusable, I can't focus any field.
Sorry for my english.
I have a project in Symfony3 and it is hosted on a Windows Server.
So, my custom command line should be executed with AT (windows) and not with CRON (unix), right ?
Does this bundle work on a windows server ?
Should I write an AT expression in the Cron expression field ??
Thank you for helping.
Maybe change last execution property to optional? So it won't require it to be set on creation.
- public function setLastExecution($lastExecution)
+ public function setLastExecution(\DateTime $lastExecution)
It would be nice to have choice list as separate field type like "commands_choice", that doing the same, without additional manipulations.
And more importantly command list generation code is not reusable, it would be good to have it as separate service, that is uncoupled from forms, so one could call it from anywhere and get commands list.
Regards.
Would it be possible to release a new version? Last one is from June and a few interesting changes have been merged to master since then...
I'm in particular interested on the fix addressed by pull request #39
Thanks a lot
I just tried to install this bundle, but got this message from Composer:
C:\mysymfonyproject-folder\ composer require jmose/command-sch
eduler-bundle
Failed loading C:\php\ext\php_xdebug-2.4.0-5.6-vc11-x86_64.dll
Using version ^1.2 for jmose/command-scheduler-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.Problem 1
- Conclusion: remove friendsofsymfony/elastica-bundle 4.0.x-dev
- Conclusion: don't install friendsofsymfony/elastica-bundle 4.0.x-dev
- don't install friendsofsymfony/elastica-bundle 4.0.x-dev|install friendsofsymfony/elastica-bundle dev-master
- Conclusion: remove ruflin/elastica 3.1.1
- Installation request for friendsofsymfony/elastica-bundle (locked at 4.0.x-dev, required as dev-master) -> satisfi
able by friendsofsymfony/elastica-bundle[4.0.x-dev].
- Conclusion: don't install ruflin/elastica 3.1.1
- friendsofsymfony/elastica-bundle dev-master requires ruflin/elastica ~2.1 -> satisfiable by ruflin/elastica[2.1.0,
2.2.0, 2.2.1, 2.3.0, 2.3.1].
- Can only install one of: ruflin/elastica[2.1.0, 3.1.1].
- Can only install one of: ruflin/elastica[2.2.0, 3.1.1].
- Can only install one of: ruflin/elastica[2.2.1, 3.1.1].
- Can only install one of: ruflin/elastica[2.3.0, 3.1.1].
- Can only install one of: ruflin/elastica[2.3.1, 3.1.1].
- Installation request for ruflin/elastica (locked at 3.1.1) -> satisfiable by ruflin/elastica[3.1.1].Installation failed, reverting ./composer.json to its original content.
I don't know what the issue is with the FOSElasticaBundle, i don't see why it should clash, given Doctrine is used as a primary datastore?
Hi,
I'm using entity from personal controller and getting sql constraint violation error, because optional entity properties have no defaults and are required by db.
I think ScheduledCommand init() method violates some OOP principles, as user of class shouldn't know about internals.
Therefore I would suggest to initialize defaults from __construct()
/**
* Constructor
*/
public function __construct()
{
$this->setLastExecution(new \DateTime);
$this->setExecuteImmediately(false);
$this->setDisabled(false);
$this->setLocked(false);
}
or remove db constraints.
I would be glad to make PR, but which way would you prefer?
Regards.
Hi,
Iam on Ubuntu 16.04, i write in the file "/etc/crontab" this command "* * * * * php /my/path/symfony/app/console scheduler:execute" (iam on symfony 2.5) and... nothing happen.
I am on version 1.1.x for this bundle.
And anything other command in my crontab works.
thanks for help.
Hi. Thanks for your bundle, it is really useful.
But I found an issue:
If some task is crushed with fatal exception (e.g. out of memory or some function returns incrorrect type in php 7+), in this case last result will not changed and task will stay locked.
E.g. if during scheduler:execute
some task is crashed:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Return value of SomeService::getUser() must be an instance of
SomeUser, null returned
In this case the next scheduler:monitor
will not show any problem.
Hi,
I configured a log path in my SF2 which does not exist yet (app/logs/scheduler
). How about extending the code to try to create the folder first and then check if it's writable (https://github.com/J-Mose/CommandSchedulerBundle/blob/master/Command/ExecuteCommand.php#L95).
Example:
// Before continue, we check that the output file is valid and writable (except for gaufrette)
if (false !== $this->logPath && strpos($this->logPath, 'gaufrette:') !== 0) {
// Create folder if it does not exist yet.
// TODO: maybe pass in folder permission and set "0744" (or s.th. else) as fallback.
if (false === is_dir($this->logPath) && false === mkdir($this->logPath, 0744, true) {
$output->writeln(
'<error>Cannot create folder "'.$this->logPath.'". Please change your `log_path` in config.yml'.'</error>'
);
return;
}
if (false === is_writable($this->logPath)) {
$output->writeln(
'<error>'.$this->logPath.
' not found or not writable. You should override `log_path` in your config.yml'.'</error>'
);
return;
}
}
In documentation I can find information:
The
--env=
and-v
(or--verbosity
) arguments are passed to all scheduled command fromscheduler:execute
, so you don't have to put these on each scheduling !
I was going mad yesterday, when I've been testing your bundle. I used cache:clear
command as example scheduled command and I wanted to clear prod
environment - it's impossible! Every time scheduler:execute
is run (without -e/--env
, so default dev
is used) and is handling scheduled cache:clear -e=prod
command, it clears dev
cache instead of requested one.
I was debugging it and -e
parameter is properly stored in ArrayInput
, but is not used (or is overriden) when command is run.
PS. I don't think forcing --verbosity
from scheduler:execute
is good too. What about situation, when I want one scheduled command to be on vvv
level and other on v
, and another without verbose option? Both options should be configurable per scheduled command.
It's a more usual way to expose configuration to users. (JMose/CommandSchedulerBundle/DependencyInjection/Configuration.php)
Might as well add option to log only errors and don't log at all.
In my use case, I need to allow manual run of disabled tasks.
When I click on the run button, UI says it will run on the next schedule command. But here's the command output.
$ app/console scheduler:execute
Start : Execute all scheduled command
Nothing to do.
An alternative would be to make cron expression optional.
hi, i trying to use your bundle for one week.
all are working perfect in SSH mode, but when i add task in anacronatb then das not work !!
i get this error :
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "scheduler:execute
" is not defined.
Did you mean one of these?
scheduler:execute
scheduler:monitor
this the command linge i deed add in anacrontab file :
@hourly 0 cron.daily-1 php -f /srv/data/web/vhosts/www.pets.me/htdocs/bin/console scheduler:execute
i dont know want to do, i m bloque.
thank
Hello,
thank you for this great bundle. It looks pretty good.
I have created multiple tasks. Some tasks needs 2 hours, another one needs 4 hours and all the other tasks are done in less than a minute. I call scheduler:execute each 5 minutes as I have a task (*/5 * * * *) which has to send all mails of a queue.
At 8 o'clock one of my 2 hour task starts. While this execution all my other tasks will start AFTER my 8 o'clock task. So, I can't send mails for a timeframe of 2 hours.
How can I allow parallel execution of my tasks?
Stefan
Is there a way to include commands that you create by yourself in the detail.command dropdown? Currently got a command that l have personally created and wanted to add it into the cron list but it doesn't seem to appear in the dropdown.
Hi, I created my own custom command. Now, I would like to get the details of the command from the table while the cron starts executing.
Curently max version of symfony core is 3.*. Any chances for symfony 4 support?
Hi,
I'm currently using the v1.2.1
version of this bundle (commit 84e86f9
) and I've stumbled upon a bug when using the log_path: false
configuration option in config.yml
. I want to disable all logging so I'm using this option as per the documentation. The problem is that when this option is set and I run the scheduler:execute
command I get the following warning:
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: fopen(): Filename cannot be empty
The problem lies on this line:
// Use a StreamOutput or NullOutput to redirect write() and writeln() in a log file
if (false === $this->logPath && "" != $scheduledCommand->getLogFile()) {
$logOutput = new NullOutput();
}else{
$logOutput = new StreamOutput(fopen(
$this->logPath . $scheduledCommand->getLogFile(), 'a', false
),$this->commandsVerbosity );
}
The first conditional is wrong, because when $this->logPath
is false and $scheduledCommand->getLogFile()
is empty (I haven't configured any log file name when creating my scheduled command) it creates an StreamOutput pointing to an empty file (hence the fopen() error) instead of using the NullOutput. I think this should be changed to:
// Use a StreamOutput or NullOutput to redirect write() and writeln() in a log file
if (false !== $this->logPath && "" != $scheduledCommand->getLogFile()) {
$logOutput = new StreamOutput(fopen(
$this->logPath . $scheduledCommand->getLogFile(), 'a', false
),$this->commandsVerbosity );
}else{
$logOutput = new NullOutput();
}
This will create an StreamOutput only if there is a proper (non false) logPath defined and the Log file name is not empty (if it's empty we can assume there is no interest in logging the output so we can disable logging for individual commands). If logPath is false or the log file name is empty we'll just use NullOutput.
Please let me know what you think (I can create a pull request with the proposed fix if you want).
Cheers,
Mikel.
For example, if a command suppose to run each minute, but the scheduler:execute command was not executed by 5 minutes, when resuming the work it should schedule 5 jobs instead of just one, this way it will "fill the gap" of jobs that were supposed to be done.
Sorry for my english,
thank you !
Commands that have been written to accept arguments cannot be run by scheduler. Every "argument" as refered to by the "Arguments" field in the command building form must actually be a Symfony "InputOption". I would like to be able to schedule commands that have required arguments so they do not need to be optional arguments when in fact they are required.
Hey, first time that i run into a big issue with your bundle on a production environment! :(
The locking strategy does not work properly. It locks the current running command only for not getting the same command again when executing scheduler:execute in parallel.
I hope my screenshot explains it better:
The point is: When a command takes longer than the time you execute scheduler:execute again, all not runned commands will getting recognized as not executed and not locked again!
Depending on how long your commands will take and how often you execute scheduler:execute as often upcoming commands will be executed in parallel.
Please add a big comment on top of your README file so everyone is aware of this problem when using it in production mode!
I try to provide a solution for it.
Hello all, i don't know what i am doing wrong, but my commands do not execute automatically after the given time i gave while creating the task. it only executes when a launch php bin/console scheduler:execute --env=env -vvv
in console.
Regards.
Create unit test and connect Travis CI
Todo list :
Hi,
I wanted to know why one of my tasks stay locked after have been executed normaly ?
The "pattern" option in file "Resources/config/routing.yml" is deprecated since Symfony version 2.2 and will be removed in 3.0. Use the "path" option in the route definition instead.
Break out the navbar section of the base template to make it overwriteable without overwriting the whole base template
Please make this Bundle available in Symfony 3
Hi im want to know if you plan to give possibility to override template so it can be possible to extends in twig, to have the possibility to "include" the main style.
Thank
Great bundle btw.
My only issue is, I have an exception listener set up to email me console command exceptions. This works fine when I run a command directly, but when it runs through the scheduler the exception is caught, so the listener can't respond to the uncaught exception and I can't be alerted.
Ideally I would rather the exception from a scheduled command not be caught so I could handle it however I want, not sure if that's possible, or some other way I could achieve this?
Cheers.
Hi,
I have an app with locale 'es'. Currently the command scheduler pages show titles like "detail.name" or "list.title". Aparently when the locale doesnt match 'en' or 'fr', it doesn't load any of the languages file in your bundle. Could you correct this so that by default it is english (in case a different locale is set in the config) ?
If you could also add the 'es' locale I would really apreciate it. I already made them following the format in your bundle, so I attach them in case you need them.
Thank you
It would useful to include only needed namespaces, rather then keep list of unneeded.
What about changing the default value of log_path
configuration property from /var/logs
to "%kernel.logs_dir%"
?
My mistake
Hi,
I have a problem tasks finishing with a successfull return code, but not being unlocked, so I found out that since the Doctrine connection is not used during the long task, it times out, and I have to reconnect it, before exiting the task.
Maybe this could be handled by the bundle - checking if the connection is still active, and reconnecting if not?
Thanks! :)
I have this depretions in Symfony 3.4.
User Deprecated: Auto-registration of the command "Symfony\Bundle\SwiftmailerBundle\Command\DebugCommand" is deprecated since Symfony 3.4 and won't be supported in 4.0. Use PSR-4 based service discovery instead.
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Bundle\Bundle.php:190
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:153
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:92
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:229
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:72
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:148
D:\wamp\www\My\vendor\jmose\command-scheduler-bundle\Service\CommandParser.php:56
D:\wamp\www\My\vendor\jmose\command-scheduler-undle\Form\Type\CommandChoiceType.php:39
D:\wamp\www\My\vendor\symfony\symfony\src\Symfony\Component\Form\ResolvedFormType.php:192
.....
Thanks,
Paulo
Hi,
really nice bundle, thank you for your work. :)
In my project I want to extend repository class, which is not possible due doctrine mappings is not overridable via bundle override. One way to solve it would be to change entity type to mapped super class, like fos user bundle is working.
On separate note, take a look at http://docs.sylius.org/en/latest/bundles/SyliusResourceBundle/ which is very much suited for your cause and could drastically improve extendability (everything become a service and one could override repo by just replacing FQCN), add some features like different managers almost for free.
Example of how repo would be overridden in case of sylius resource bundle http://docs.sylius.org/en/latest/bundles/general/overriding_repositories.html
Let me know if I could assist you with this.
Regards.
Replace parameters with bundle configuration and handle backward compatibility.
in command-scheduler/detail/new
, there is no label for the 2 checkboxes at the end of the page:
solution :
replace
{{ form_widget( scheduledCommandForm.disabled ) }}
{{ form_label( scheduledCommandForm.disabled ) }}
by
{{ form_row( scheduledCommandForm.disabled ) }}
in views/Detail/index.html.twig
Hi,
i have created a custom command and it is correctly listed in command list to be executed. When i try to add a dependecy injection like
`
public function __construct(CustomRepository $repo)
{
$this->repo = $repo;
parent::__construct();
}
`
command disappear from list and i'm not able to schedule it. Why? Thanks, best regards
Hi, I have given log_path in the configuration file. But I am getting below error.
php.INFO: Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.
Is there a fix for this ?
This bundle is not compatible with Symfony 3.4 due to restrictions in sensio/framework-extra-bundle
SF3.4 requires sensio/framework-extra-bundle version ^5.0.0 https://github.com/symfony/symfony-standard/blob/3.4/composer.json#L22
while this bundle requires ^3.0.2"
Are there any plans to fix this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.