You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bundle provides a [PhpRunner](https://github.com/luzrain/phprunner) integration with Symfony framework to run your application in a highly efficient event-loop based runtime.
\* For better performance, install the _php-uv_ extension.
59
49
60
50
## Reload strategies
61
-
Because of the asynchronous nature of the server, the workers reuse loaded resources on each request. This means that in some cases we need to restart workers.
62
-
For example, after an exception is thrown, to prevent services from being in an unrecoverable state. Or every time you change the code in the IDE.
63
-
There are a few restart strategies that are implemented and can be enabled or disabled depending on the environment.
64
-
65
-
-**exception**
66
-
Reload worker each time that an exception is thrown during the request handling.
67
-
-**max_requests**
68
-
Reload worker on every N request to prevent memory leaks.
69
-
-**file_monitor**
70
-
Reload all workers each time you change the files**.
71
-
-**always**
72
-
Reload worker after each request.
51
+
Because of the asynchronous nature of the server, the workers reuse loaded resources on each request.
52
+
This means that in some cases we need to restart workers.
53
+
For example, after an exception is thrown, to prevent services from being in an unrecoverable state.
54
+
Or every time you change the code in the IDE in dev environment.
55
+
The bundle provides several restart strategies that can be configured depending on what you need.
56
+
57
+
-**on_exception**
58
+
Reload worker each time that an exception is thrown during the worker lifetime.
59
+
-**on_each_request**
60
+
Reload worker after each http request. This strategy is for debug purposes.
61
+
-**on_ttl_limit**
62
+
Reload worker after TTL lifiteme will be reached. Can be used to prevent memory leaks.
63
+
-**on_requests_limit**
64
+
Reload worker on every N request.
65
+
-**on_memory_limit**
66
+
Reload worker after memory usage exceeds threshold value.
67
+
-**on_file_change**
68
+
Reload all workers each time that monitored files are changed. **
73
69
74
70
** It is highly recommended to install the _php-inotify_ extension for file monitoring. Without it, monitoring will work in polling mode, which can be very cpu and disk intensive for large projects.
75
71
@@ -78,60 +74,63 @@ See all available options for each strategy in the command output.
Periodic tasks can be configured with attributes or with tags in configuration files.
83
-
Schedule string can be formatted in several ways:
90
+
Periodic tasks can schedule the execution of external programs as well as internal Symfony application commands.
91
+
To run a Symfony command, simply type the command name without any prefixes.
92
+
Schedule string can be formatted in several ways:
84
93
- An integer to define the frequency as a number of seconds. Example: _60_
85
-
- An ISO8601 datetime format. Example: _2023-08-01T01:00:00+08:00_
94
+
- An ISO8601 datetime format. Example: _2024-02-14T018:00:00+08:00_
86
95
- An ISO8601 duration format. Example: _PT1M_
87
96
- A relative date format as supported by DateInterval. Example: _1 minutes_
88
97
- A cron expression**. Example: _*/1 * * * *_
89
98
90
99
** Note that you need to install the [dragonmantank/cron-expression](https://github.com/dragonmantank/cron-expression) package if you want to use cron expressions as schedule strings
91
100
92
-
```php
93
-
<?php
101
+
```yaml
102
+
# config/packages/phprunner.yaml
94
103
95
-
use Luzrain\PhpRunnerBundle\Attribute\AsTask;
96
-
97
-
/**
98
-
* Attribute parameters
99
-
* name: Task name
100
-
* schedule: Task schedule in any format
101
-
* method: method to call, __invoke by default
102
-
* jitter: Maximum jitter in seconds that adds a random time offset to the schedule. Use to prevent multiple tasks from running at the same time
0 commit comments