diff --git a/cron-command.php b/cron-command.php index 68a5f89..770e5db 100644 --- a/cron-command.php +++ b/cron-command.php @@ -4,6 +4,10 @@ return; } +if ( ! defined( 'EE_CRON_SCHEDULER' ) ) { + define( 'EE_CRON_SCHEDULER', 'ee-cron-scheduler' ); +} + $autoload = dirname( __FILE__ ) . '/vendor/autoload.php'; if ( file_exists( $autoload ) ) { require_once $autoload; diff --git a/src/Cron_Command.php b/src/Cron_Command.php index 3039e2b..c1398cc 100644 --- a/src/Cron_Command.php +++ b/src/Cron_Command.php @@ -1,3 +1,4 @@ + update_cron_config(); + EE::success( 'Cron created successfully' ); EE\Utils\delem_log( 'ee cron add end' ); } @@ -160,7 +164,7 @@ private function update_cron_config() { $config = $this->generate_cron_config(); file_put_contents( EE_ROOT_DIR . '/services/cron/config.ini', $config ); - EE_DOCKER::restart_container( 'ee-cron-scheduler' ); + EE_DOCKER::restart_container( EE_CRON_SCHEDULER ); } /** @@ -294,6 +298,8 @@ public function update( $args, $assoc_args ) { $this->update_cron_config(); + EE::success( 'Cron update Successfully'); + EE\Utils\delem_log( 'ee cron add end' ); } @@ -402,5 +408,10 @@ public function delete( $args ) { $this->update_cron_config(); EE::success( 'Deleted cron with id ' . $id ); + + $cron_entries = Cron::all(); + if ( empty( $cron_entries ) ) { + EE::exec( 'docker rm -f ' . EE_CRON_SCHEDULER ); + } } }