Comments (2)
Hi @lokhman! Thanks for using and trusing this project :-).
At the moment it's not possible to run this in daemon mode. I would love to add this as I like the feature! Maybe there are already other projects allowing you to get this behaviour but it feels like something this project can provide.
I would suggest implementing a -d
flag on cron:run
to make it start in daemon mode.
As my schedule is really packed at the moment, feel free to implement it.
Maybe https://reactphp.org/event-loop/ is a good starting point to get this working.
Feel free to ask any questions you want answered. I'll try to get back to you quicker than I did just now.
from symfony-bundle.
Thank you, @NoUseFreak, for the reply!
As this feature was not available in the library and I needed a fast solution to embed one in the project, I wrote a very simple console script, which so far works very well:
#!/usr/bin/env php
<?php
use Symfony\Component\Process\Process;
umask(0000);
set_time_limit(0);
require __DIR__.'/../vendor/autoload.php';
$process = new Process(__DIR__.'/console cron:run');
$process->setTimeout(0);
while (true) {
$now = microtime(true);
usleep((60 - ($now % 60) + (int) $now - $now) * 1e6);
if (!$process->isRunning()) {
$process->start();
}
}
This behaves like a synchronous crontab, which runs cron:run
command exactly every minute (0 * * * *
). Saying "synchronous" I mean that if a command gets executed for more than a minute, it will skip the next execution. In my project this will never happen, although making it asynchronous should not be a big problem.
I was also looking at event-loop library, but thought that probably for this kind of task utilising a full-featured event extension is a bit of an overkill, which will require an extra dependency. Component symfony/process
has enough functionality to execute commands asynchronously, while making a simple queue should be a trivial task. What do you think? Is there anything I'm missing?
from symfony-bundle.
Related Issues (20)
- Allow use of cron:delete without interaction
- Automatically update the schedule of a cron after database update HOT 1
- Syntax error cPanel
- Could not open input file: ../bin/console HOT 1
- Best pratice to hook to cron job errors and send notification ? HOT 3
- Raw is Deprecated HOT 2
- cron:start fails silently HOT 2
- Support for Symfony 6.1 and 6.2 HOT 3
- Cron not working with Symfony 6.4 HOT 3
- Add symfony 7 support
- Error - doctrine.orm.default_annotation_metadata_driver HOT 4
- Error in ShellJob.php with Symfony\Component\Process\Process in cron bundle v3.0.0
- Compile Error: Declaration of Cron\CronBundle\Job\ShellJobWrapper HOT 3
- Multiple accumulative jobs executions HOT 3
- Proble with return type form method execute in Commands HOT 1
- Can't create migration HOT 1
- PHPUnit test errors
- The target-entity Cron\\CronBundle\\Entity\\job cannot be found HOT 1
- Error passing parameters with version 2.18.0 of doctrine/orm
- Cron Job Runs Every Minute Instead of at Specific Minute HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symfony-bundle.