/** * Run a scheduled command * * @param \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $scheduledCommand * @param array $arguments * @param array $options * @return bool */ public function run(ScheduledCommandInterface $scheduledCommand, array $arguments = [], array $options = [], Debugger $debugger = null) { $runCommand = $this->commandService->getRunCommand($scheduledCommand, $arguments, $options); if (!is_null($debugger)) { $debugger->commandRun($scheduledCommand, $runCommand); } exec($runCommand); return true; }
public function testGetRunCommandAsUser() { $user = '******'; $commandName = 'test:command'; $scheduledCommand = $this->mockCommand(); $scheduledCommand->shouldReceive('getName')->andReturn($commandName); $scheduledCommand->shouldReceive('user')->andReturn($user); $this->assertEquals($this->commandService->getRunCommand($scheduledCommand), implode(' ', array('sudo -u ' . $user, '/usr/bin/env', 'php', base_path() . '/artisan', $commandName, '> /dev/null', '&'))); }
public function testGetRunCommandAsUser() { $user = '******'; $commandName = 'test:command'; $scheduledCommand = $this->mockCommand(); $scheduledCommand->shouldReceive('getName')->andReturn($commandName); $scheduledCommand->shouldReceive('user')->andReturn($user); $this->assertEquals($this->commandService->getRunCommand($scheduledCommand), implode(' ', ['sudo -u ' . $user, PHP_BINARY, base_path() . '/artisan', $commandName, '--env=' . App::environment(), '> /dev/null', '&'])); }