Enable job

@return void
162018
public function enableJobAction()
    {
        $code = $this->getArg('code');
        if (empty($code)) {
            echo "\nNo code found!\n\n";
            echo $this->usageHelp();
            exit(1);
        }

        $allowedCodes = Mage::getSingleton('aoe_scheduler/job')->getResource()->getJobCodes();
        if (!in_array($code, $allowedCodes)) {
            echo "\nNo valid job found!\n\n";
            echo $this->usageHelp();
            exit(1);
        }

        $job = Mage::getModel('aoe_scheduler/job')->load($code); /* @var Aoe_Scheduler_Model_Job $job */
        if (!$job->getJobCode()) {
            echo "Job '$code' not found\n";
            exit(1);
        }

        if ($job->getIsActive()) {
            echo "Job '$code' is already active. Skipping.'";
            return;
        }

        $job->setIsActive(true)->save();

        $scheduleManager = Mage::getModel('aoe_scheduler/scheduleManager'); /* @var Aoe_Scheduler_Model_ScheduleManager $scheduleManager */
        $scheduleManager->generateSchedulesForJob($job);

        echo "Enabled job $code and generated schedules\n";
    }
561200
public function enable()
    {
        $configModel = new Configuration();
        $this->enable = $configModel->getConfiguration(self::CONFIG_KEY);

        return $this->enable;
    }
753949
public function enable()
    {
        $this->manager->enable($this);

        if ($this->referenced) {
            $this->manager->reference($this);
        }
    }
1054842
private function addJobs()
    {
        foreach ($this->cronjobs as $jobName => $jobConfig) {
            $this->addJob($jobName, $jobConfig);
        }
    }
165640
protected function main(): void
    {
        $this->logger->info('start job listener', [
            'category' => get_class($this),
        ]);

        $cursor_jobs = $this->jobs->getCursor([
            '$or' => [
                ['status' => JobInterface::STATUS_WAITING],
                ['status' => JobInterface::STATUS_POSTPONED],
            ],
        ]);

        $cursor_events = $this->events->getCursor([
            'timestamp' => ['$gte' => new UTCDateTime()],
            'job' => ['$exists' => true],
            'status' => ['$gt' => JobInterface::STATUS_POSTPONED],
        ]);

        $this->catchSignal();

        while ($this->loop()) {
            while ($this->loop()) {
                if (null === $cursor_events->current()) {
                    if ($cursor_events->getInnerIterator()->isDead()) {
                        $this->logger->error('event queue cursor is dead, is it a capped collection?', [
                            'category' => get_class($this),
                        ]);

                        $this->events->create();

                        $this->main();

                        break;
                    }

                    $this->events->next($cursor_events, function () {
                        $this->main();
                    });
                }

                $event = $cursor_events->current();
                $this->events->next($cursor_events, function () {
                    $this->main();
                });

                if($event === null) {
                    break;
                }

                $this->handleEvent($event);
            }

            if (null === $cursor_jobs->current()) {
                if ($cursor_jobs->getInnerIterator()->isDead()) {
                    $this->logger->error('job queue cursor is dead, is it a capped collection?', [
                        'category' => get_class($this),
                    ]);

                    $this->jobs->create();
                    $this->main();

                    break;
                }

                $this->jobs->next($cursor_jobs, function () {
                    $this->main();
                });

                continue;
            }

            $job = $cursor_jobs->current();

            $this->jobs->next($cursor_jobs, function () {
                $this->main();
            });

            $this->handleJob($job);
        }
    }
811395
protected function job(): void
    {
        while (true) {

            $starbases = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($starbases->isCachedLoad()) return;

            collect($starbases)->each(function ($starbase) {

                CorporationStarbase::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'starbase_id'    => $starbase->starbase_id,
                ])->fill([
                    'moon_id'          => $starbase->moon_id ?? null,
                    'onlined_since'    => property_exists($starbase, 'onlined_since') ?
                        carbon($starbase->onlined_since) : null,
                    'reinforced_until' => property_exists($starbase, 'reinforced_until') ?
                        carbon($starbase->reinforced_until) : null,
                    'state'            => $starbase->state ?? null,
                    'type_id'          => $starbase->type_id,
                    'system_id'        => $starbase->system_id,
                    'unanchor_at'      => property_exists($starbase, 'unanchor_at') ?
                        carbon($starbase->unanchor_at) : null,
                ])->save();

                $this->known_starbases->push($starbase->starbase_id);

            });

            if (! $this->nextPage($starbases->pages))
                break;
        }

        CorporationStarbase::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('starbase_id', $this->known_starbases->flatten()->all())
            ->delete();
    }
741467
def register_jobs(commands, callable)
      commands.each do |command|
        register_job do
          JobWrapper.call(command,callable)
        end
      end
    end
47786
protected function job(): void
    {
        while (true) {

            $orders = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($orders->isCachedLoad()) return;

            collect($orders)->each(function ($order) {

                CorporationOrder::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'order_id'       => $order->order_id,
                ])->fill([
                    'type_id'         => $order->type_id,
                    'region_id'       => $order->region_id,
                    'location_id'     => $order->location_id,
                    'range'           => $order->range,
                    'is_buy_order'    => $order->is_buy_order ?? null,
                    'price'           => $order->price,
                    'volume_total'    => $order->volume_total,
                    'volume_remain'   => $order->volume_remain,
                    'issued'          => carbon($order->issued),
                    'issued_by'       => $order->issued_by,
                    'min_volume'      => $order->min_volume ?? null,
                    'wallet_division' => $order->wallet_division ?? null,
                    'duration'        => $order->duration ?? null,
                    'escrow'          => $order->escrow ?? null,
                ])->save();
            });

            if (! $this->nextPage($orders->pages))
                return;
        }
    }
221039
def EnableJob(self, job_id, token=None):
    """"""
    job_urn = self.CRON_JOBS_PATH.Add(job_id)
    cron_job = aff4.FACTORY.Open(
        job_urn, mode="rw", aff4_type=CronJob, token=token)
    cron_job.Set(cron_job.Schema.DISABLED(0))
    cron_job.Close()
758276
public static function enable()
    {
        self::$startValues = array(
            'time' => microtime(true),
            'realmem' => memory_get_usage(true),
            // 'emalloc' => memory_get_usage(false)
        );
        self::$_enabled = true;
    }
1304040
protected function job(): void
    {
        $members = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($members->isCachedLoad()) return;

        collect($members)->each(function ($member) {

            CorporationMemberTracking::firstOrNew([
                'corporation_id' => $this->getCorporationId(),
                'character_id'   => $member->character_id,
            ])->fill([
                'start_date'   => property_exists($member, 'start_date') ?
                    carbon($member->start_date) : null,
                'base_id'      => $member->base_id ?? null,
                'logon_date'   => property_exists($member, 'logon_date') ?
                    carbon($member->logon_date) : null,
                'logoff_date'  => property_exists($member, 'logoff_date') ?
                    carbon($member->logoff_date) : null,
                'location_id'  => $member->location_id ?? null,
                'ship_type_id' => $member->ship_type_id ?? null,
            ])->save();
        });

        CorporationMemberTracking::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('character_id', collect($members)->pluck('character_id')->all())
            ->delete();
    }
808727
protected function job(): void
    {
        while (true) {

            $roles = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($roles->isCachedLoad()) return;

            collect($roles)->each(function ($role) {

                collect($role->old_roles)->each(function ($role_id) use ($role) {

                    CorporationRoleHistory::firstOrNew([
                        'corporation_id' => $this->getCorporationId(),
                        'character_id'   => $role->character_id,
                        'changed_at'     => carbon($role->changed_at),
                        'role_type'      => $role->role_type,
                        'state'          => 'old',
                        'role'           => $role_id,
                    ])->fill([
                        'issuer_id' => $role->issuer_id,
                    ])->save();

                });

                collect($role->new_roles)->each(function ($role_id) use ($role) {

                    CorporationRoleHistory::firstOrNew([
                        'corporation_id' => $this->getCorporationId(),
                        'character_id'   => $role->character_id,
                        'changed_at'     => carbon($role->changed_at),
                        'role_type'      => $role->role_type,
                        'state'          => 'new',
                        'role'           => $role_id,
                    ])->fill([
                        'issuer_id' => $role->issuer_id,
                    ])->save();

                });

            });

            if (! $this->nextPage($roles->pages))
                break;
        }
    }
207421
protected function job(): void
    {
        while (true) {

            $shareholders = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($shareholders->isCachedLoad()) return;

            collect($shareholders)->each(function ($shareholder) {

                CorporationShareholder::firstOrNew([
                    'corporation_id'   => $this->getCorporationId(),
                    'shareholder_type' => $shareholder->shareholder_type,
                    'shareholder_id'   => $shareholder->shareholder_id,
                ])->fill([
                    'share_count' => $shareholder->share_count,
                ])->save();

            });

            $this->known_shareholders->push(collect($shareholders)
                ->pluck(['shareholder_type', 'shareholder_id'])->flatten()->all());

            if (! $this->nextPage($shareholders->pages))
                break;
        }

        CorporationShareholder::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('shareholder_id', $this->known_shareholders->flatten()->all())
            ->delete();
    }
973244
public static function enable()
    {
        Builder::macro(self::MACRO_METHOD, function (Fluent $builder, $createdAt = 'createdAt', $updatedAt = 'updatedAt', $type = 'dateTime') {
            $builder->{$type}($createdAt)->timestampable()->onCreate();
            $builder->{$type}($updatedAt)->timestampable()->onUpdate();
        });
    }
1278340
public function loadConfiguration(): void
	{
		$builder = $this->getContainerBuilder();
		$config = $this->validateConfig($this->defaults);
		$config = Helpers::expand($config, $builder->parameters);

		// Scheduler
		$scheduler = $builder->addDefinition($this->prefix('scheduler'))
			->setFactory(LockingScheduler::class, [$config['path']]);

		// Commands
		$builder->addDefinition($this->prefix('runCommand'))
			->setFactory(RunCommand::class)
			->setAutowired(false);
		$builder->addDefinition($this->prefix('listCommand'))
			->setFactory(ListCommand::class)
			->setAutowired(false);
		$builder->addDefinition($this->prefix('helpCommand'))
			->setFactory(HelpCommand::class)
			->setAutowired(false);

		// Jobs
		foreach ($config['jobs'] as $key => $job) {
			if (is_array($job)) {
				$job = new Statement(CallbackJob::class, [$job['cron'], $job['callback']]);
			} else {
				$job = new Statement($job);
			}

			$scheduler->addSetup('add', [$job, $key]);
		}
	}
728493
def job_enable(self, job_id):
		
		job_id = normalize_job_id(job_id)
		with self._job_lock:
			job_desc = self._jobs[job_id]
			job_desc['enabled'] = True
858506
protected function job(): void
    {
        while (true) {

            $industry_jobs = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($industry_jobs->isCachedLoad()) return;

            collect($industry_jobs)->each(function ($job) {

                CorporationIndustryJob::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'job_id'         => $job->job_id,
                ])->fill([
                    'installer_id'           => $job->installer_id,
                    'facility_id'            => $job->facility_id,
                    'location_id'            => $job->location_id,
                    'activity_id'            => $job->activity_id,
                    'blueprint_id'           => $job->blueprint_id,
                    'blueprint_type_id'      => $job->blueprint_type_id,
                    'blueprint_location_id'  => $job->blueprint_location_id,
                    'output_location_id'     => $job->output_location_id,
                    'runs'                   => $job->runs,
                    'cost'                   => $job->cost ?? null,
                    'licensed_runs'          => $job->licensed_runs ?? null,
                    'probability'            => $job->probability ?? null,
                    'product_type_id'        => $job->product_type_id ?? null,
                    'status'                 => $job->status,
                    'duration'               => $job->duration,
                    'start_date'             => carbon($job->start_date),
                    'end_date'               => carbon($job->end_date),
                    'pause_date'             => property_exists($job, 'pause_date') ?
                        carbon($job->pause_date) : null,
                    'completed_date'         => property_exists($job, 'completed_date') ?
                        carbon($job->completed_date) : null,
                    'completed_character_id' => $job->completed_character_id ?? null,
                    'successful_runs'        => $job->successful_runs ?? null,
                ])->save();
            });

            if (! $this->nextPage($industry_jobs->pages))
                return;
        }
    }