@@ -35,59 +35,59 @@ class ProcessCronQueueObserver implements ObserverInterface
3535 /**#@+
3636 * Cache key values
3737 */
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 ' ;
3939
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 ' ;
4141
4242 /**
4343 * Flag for internal communication between processes for running
4444 * all jobs in a group in parallel as a separate process
4545 */
46- const STANDALONE_PROCESS_STARTED = 'standaloneProcessStarted ' ;
46+ public const STANDALONE_PROCESS_STARTED = 'standaloneProcessStarted ' ;
4747
4848 /**#@-*/
4949
5050 /**#@+
5151 * List of configurable constants used to calculate and validate during handling cron jobs
5252 */
53- const XML_PATH_SCHEDULE_GENERATE_EVERY = 'schedule_generate_every ' ;
53+ public const XML_PATH_SCHEDULE_GENERATE_EVERY = 'schedule_generate_every ' ;
5454
55- const XML_PATH_SCHEDULE_AHEAD_FOR = 'schedule_ahead_for ' ;
55+ public const XML_PATH_SCHEDULE_AHEAD_FOR = 'schedule_ahead_for ' ;
5656
57- const XML_PATH_SCHEDULE_LIFETIME = 'schedule_lifetime ' ;
57+ public const XML_PATH_SCHEDULE_LIFETIME = 'schedule_lifetime ' ;
5858
59- const XML_PATH_HISTORY_CLEANUP_EVERY = 'history_cleanup_every ' ;
59+ public const XML_PATH_HISTORY_CLEANUP_EVERY = 'history_cleanup_every ' ;
6060
61- const XML_PATH_HISTORY_SUCCESS = 'history_success_lifetime ' ;
61+ public const XML_PATH_HISTORY_SUCCESS = 'history_success_lifetime ' ;
6262
63- const XML_PATH_HISTORY_FAILURE = 'history_failure_lifetime ' ;
63+ public const XML_PATH_HISTORY_FAILURE = 'history_failure_lifetime ' ;
6464
6565 /**#@-*/
6666
6767 /**
6868 * Value of seconds in one minute
6969 */
70- const SECONDS_IN_MINUTE = 60 ;
70+ public const SECONDS_IN_MINUTE = 60 ;
7171
7272 /**
7373 * How long to wait for cron group to become unlocked
7474 */
75- const LOCK_TIMEOUT = 60 ;
75+ public const LOCK_TIMEOUT = 60 ;
7676
7777 /**
7878 * Static lock prefix for cron group locking
7979 */
80- const LOCK_PREFIX = 'CRON_ ' ;
80+ public const LOCK_PREFIX = 'CRON_ ' ;
8181
8282 /**
8383 * Timer ID for profiling
8484 */
85- const CRON_TIMERID = 'job %s ' ;
85+ public const CRON_TIMERID = 'job %s ' ;
8686
8787 /**
8888 * Max retries for acquire locks for cron jobs
8989 */
90- const MAX_RETRIES = 5 ;
90+ public const MAX_RETRIES = 5 ;
9191
9292 /**
9393 * @var ScheduleCollection
@@ -365,18 +365,9 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
365365 );
366366 }
367367
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 );
378369
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 ()));
380371 $ this ->retrier ->execute (
381372 function () use ($ schedule ) {
382373 $ schedule ->save ();
@@ -954,4 +945,24 @@ function () use ($scheduleResource, $where) {
954945 $ scheduleResource ->getConnection ()
955946 );
956947 }
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+ }
957968}
0 commit comments