login notify + bonus log

This commit is contained in:
xiaomlove
2023-01-31 16:38:21 +08:00
parent 3edb283b62
commit 9c0f458920
26 changed files with 552 additions and 7 deletions
+8 -2
View File
@@ -1113,18 +1113,24 @@ function get_passkey_by_authkey($authkey)
});
}
function executeCommand($command, $format = 'string'): string|array
function executeCommand($command, $format = 'string', $artisan = false, $exception = true): string|array
{
$append = " 2>&1";
if (!str_ends_with($command, $append)) {
$command .= $append;
}
if ($artisan) {
$phpPath = nexus_env('PHP_PATH', 'php');
$webRoot = rtrim(ROOT_PATH, '/');
$command = "$phpPath $webRoot/artisan $command";
}
do_log("command: $command");
$result = exec($command, $output, $result_code);
$outputString = implode("\n", $output);
do_log(sprintf('result_code: %s, result: %s, output: %s', $result_code, $result, $outputString));
if ($result_code != 0) {
if ($exception && $result_code != 0) {
throw new \RuntimeException($outputString);
}
return $format == 'string' ? $outputString : $output;
}