初始上传
This commit is contained in:
34
vendor/yunwuxin/think-cron/src/cron/command/Schedule.php
vendored
Executable file
34
vendor/yunwuxin/think-cron/src/cron/command/Schedule.php
vendored
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace yunwuxin\cron\command;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
|
||||
class Schedule extends Command
|
||||
{
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('cron:schedule');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
|
||||
if ('\\' == DIRECTORY_SEPARATOR) {
|
||||
$command = 'start /B "Niushop Schedule" "' . PHP_BINARY . '" think cron:run';
|
||||
} else {
|
||||
$command = 'nohup "' . PHP_BINARY . '" think cron:run >> /dev/null 2>&1 &';
|
||||
}
|
||||
|
||||
$process = Process::fromShellCommandline($command);
|
||||
$output->writeln('['.date('Y-m-d H:i:s').'] Schedule:start');
|
||||
while (true) {
|
||||
$process->run();
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user