@@ -35,59 +35,59 @@ class ProcessCronQueueObserver implements ObserverInterface
35
35
/**#@+
36
36
* Cache key values
37
37
*/
38
- const CACHE_KEY_LAST_SCHEDULE_GENERATE_AT = 'cron_last_schedule_generate_at ' ;
38
+ public const CACHE_KEY_LAST_SCHEDULE_GENERATE_AT = 'cron_last_schedule_generate_at ' ;
39
39
40
- const CACHE_KEY_LAST_HISTORY_CLEANUP_AT = 'cron_last_history_cleanup_at ' ;
40
+ public const CACHE_KEY_LAST_HISTORY_CLEANUP_AT = 'cron_last_history_cleanup_at ' ;
41
41
42
42
/**
43
43
* Flag for internal communication between processes for running
44
44
* all jobs in a group in parallel as a separate process
45
45
*/
46
- const STANDALONE_PROCESS_STARTED = 'standaloneProcessStarted ' ;
46
+ public const STANDALONE_PROCESS_STARTED = 'standaloneProcessStarted ' ;
47
47
48
48
/**#@-*/
49
49
50
50
/**#@+
51
51
* List of configurable constants used to calculate and validate during handling cron jobs
52
52
*/
53
- const XML_PATH_SCHEDULE_GENERATE_EVERY = 'schedule_generate_every ' ;
53
+ public const XML_PATH_SCHEDULE_GENERATE_EVERY = 'schedule_generate_every ' ;
54
54
55
- const XML_PATH_SCHEDULE_AHEAD_FOR = 'schedule_ahead_for ' ;
55
+ public const XML_PATH_SCHEDULE_AHEAD_FOR = 'schedule_ahead_for ' ;
56
56
57
- const XML_PATH_SCHEDULE_LIFETIME = 'schedule_lifetime ' ;
57
+ public const XML_PATH_SCHEDULE_LIFETIME = 'schedule_lifetime ' ;
58
58
59
- const XML_PATH_HISTORY_CLEANUP_EVERY = 'history_cleanup_every ' ;
59
+ public const XML_PATH_HISTORY_CLEANUP_EVERY = 'history_cleanup_every ' ;
60
60
61
- const XML_PATH_HISTORY_SUCCESS = 'history_success_lifetime ' ;
61
+ public const XML_PATH_HISTORY_SUCCESS = 'history_success_lifetime ' ;
62
62
63
- const XML_PATH_HISTORY_FAILURE = 'history_failure_lifetime ' ;
63
+ public const XML_PATH_HISTORY_FAILURE = 'history_failure_lifetime ' ;
64
64
65
65
/**#@-*/
66
66
67
67
/**
68
68
* Value of seconds in one minute
69
69
*/
70
- const SECONDS_IN_MINUTE = 60 ;
70
+ public const SECONDS_IN_MINUTE = 60 ;
71
71
72
72
/**
73
73
* How long to wait for cron group to become unlocked
74
74
*/
75
- const LOCK_TIMEOUT = 60 ;
75
+ public const LOCK_TIMEOUT = 60 ;
76
76
77
77
/**
78
78
* Static lock prefix for cron group locking
79
79
*/
80
- const LOCK_PREFIX = 'CRON_ ' ;
80
+ public const LOCK_PREFIX = 'CRON_ ' ;
81
81
82
82
/**
83
83
* Timer ID for profiling
84
84
*/
85
- const CRON_TIMERID = 'job %s ' ;
85
+ public const CRON_TIMERID = 'job %s ' ;
86
86
87
87
/**
88
88
* Max retries for acquire locks for cron jobs
89
89
*/
90
- const MAX_RETRIES = 5 ;
90
+ public const MAX_RETRIES = 5 ;
91
91
92
92
/**
93
93
* @var ScheduleCollection
@@ -365,18 +365,9 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
365
365
);
366
366
}
367
367
368
- if (!isset ($ this ->originalProcessTitle )) {
369
- $ this ->originalProcessTitle = PHP_BINARY . ' ' . implode (' ' , $ this ->environment ->getServer ('argv ' ));
370
- }
371
-
372
- if (strpos ($ this ->originalProcessTitle , " --group= $ groupId " ) !== false ) {
373
- // Group is already shown, so no need to include here in duplicate
374
- cli_set_process_title ($ this ->originalProcessTitle . " # job: $ jobCode " );
375
- } else {
376
- cli_set_process_title ($ this ->originalProcessTitle . " # group: $ groupId, job: $ jobCode " );
377
- }
368
+ $ this ->setProcessTitle ($ jobCode , $ groupId );
378
369
379
- $ schedule ->setExecutedAt (strftime ( ' %Y-%m-%d %H:%M:%S ' , $ this ->dateTime ->gmtTimestamp ()));
370
+ $ schedule ->setExecutedAt (date ( ' Y-m-d H:i:s ' , $ this ->dateTime ->gmtTimestamp ()));
380
371
$ this ->retrier ->execute (
381
372
function () use ($ schedule ) {
382
373
$ schedule ->save ();
@@ -954,4 +945,24 @@ function () use ($scheduleResource, $where) {
954
945
$ scheduleResource ->getConnection ()
955
946
);
956
947
}
948
+
949
+ /**
950
+ * Set the process title to include the job code and group
951
+ *
952
+ * @param string $jobCode
953
+ * @param string $groupId
954
+ */
955
+ private function setProcessTitle (string $ jobCode , string $ groupId ): void
956
+ {
957
+ if (!isset ($ this ->originalProcessTitle )) {
958
+ $ this ->originalProcessTitle = PHP_BINARY . ' ' . implode (' ' , $ this ->environment ->getServer ('argv ' ));
959
+ }
960
+
961
+ if (strpos ($ this ->originalProcessTitle , " --group= $ groupId " ) !== false ) {
962
+ // Group is already shown, so no need to include here in duplicate
963
+ cli_set_process_title ($ this ->originalProcessTitle . " # job: $ jobCode " );
964
+ } else {
965
+ cli_set_process_title ($ this ->originalProcessTitle . " # group: $ groupId, job: $ jobCode " );
966
+ }
967
+ }
957
968
}
0 commit comments