Skip to content

Commit bfa1dd1

Browse files
author
ziming
committed
Catch the process timed out exceptions
1 parent daf6237 commit bfa1dd1

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/Commands/StatsigSendCommand.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Ziming\LaravelStatsig\Commands;
66

7+
use Exception;
78
use Illuminate\Console\Command;
9+
use Illuminate\Process\Exceptions\ProcessTimedOutException;
810
use Illuminate\Support\Facades\Process;
911
use Statsig\Adapters\LocalFileLoggingAdapter;
1012

@@ -52,9 +54,16 @@ public function handle(): int
5254
$commandToRun .= ' '.$key.' '.$value;
5355
}
5456

55-
$result = Process::run($commandToRun);
56-
$this->info($result->output());
57+
try {
58+
$result = Process::run($commandToRun);
59+
$this->info($result->output());
60+
return self::SUCCESS;
61+
} catch (ProcessTimedOutException $e) {
62+
report(
63+
new Exception('php ./vendor/statsig/statsigsdk/send.php has timed out')
64+
);
65+
}
5766

58-
return $result->exitCode();
67+
return self::FAILURE;
5968
}
6069
}

src/Commands/StatsigSyncCommand.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Ziming\LaravelStatsig\Commands;
66

7+
use Exception;
78
use Illuminate\Console\Command;
9+
use Illuminate\Process\Exceptions\ProcessTimedOutException;
810
use Illuminate\Support\Facades\Process;
911

1012
class StatsigSyncCommand extends Command
@@ -33,9 +35,17 @@ public function handle(): int
3335
$commandToRun .= ' '.$key.' '.$value;
3436
}
3537

36-
$result = Process::run($commandToRun);
37-
$this->info($result->output());
3838

39-
return $result->exitCode();
39+
try {
40+
$result = Process::run($commandToRun);
41+
$this->info($result->output());
42+
return self::SUCCESS;
43+
} catch (ProcessTimedOutException $e) {
44+
report(
45+
new Exception('php ./vendor/statsig/statsigsdk/sync.php has timed out')
46+
);
47+
}
48+
49+
return self::FAILURE;
4050
}
4151
}

0 commit comments

Comments
 (0)