Fix webhook: absolute paths, nohup exec
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-12
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||||||
// Runs as the dobetternorge user via SuexecUserGroup.
|
// Runs as the dobetternorge user via SuexecUserGroup.
|
||||||
|
|
||||||
define('DEPLOY_SECRET', '59defe48282805e0706e556c39ecc852c3aa5d8f2598be378c68ac4a6a4b5813');
|
define('DEPLOY_SECRET', '59defe48282805e0706e556c39ecc852c3aa5d8f2598be378c68ac4a6a4b5813');
|
||||||
define('DEPLOY_SCRIPT', __DIR__ . '/../../../bin/deploy-tools.sh');
|
define('DEPLOY_SCRIPT', '/home/dobetternorge/bin/deploy-tools.sh');
|
||||||
define('LOG_FILE', __DIR__ . '/../../../logs/deploy-tools.log');
|
define('LOG_FILE', '/home/dobetternorge/logs/deploy-tools.log');
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
@@ -32,15 +32,7 @@ if ($ref !== 'refs/heads/main') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fire-and-forget — respond immediately, deploy runs in background
|
// Fire-and-forget — respond immediately, deploy runs in background
|
||||||
$logFile = LOG_FILE;
|
$cmd = 'nohup ' . escapeshellarg(DEPLOY_SCRIPT) . ' >> ' . escapeshellarg(LOG_FILE) . ' 2>&1 &';
|
||||||
$script = DEPLOY_SCRIPT;
|
shell_exec($cmd);
|
||||||
$cmd = "bash {$script} >> {$logFile} 2>&1";
|
|
||||||
if (function_exists('proc_open')) {
|
|
||||||
$desc = [['pipe', 'r'], ['file', $logFile, 'a'], ['file', $logFile, 'a']];
|
|
||||||
$proc = proc_open('bash ' . escapeshellarg($script), $desc, $pipes, null, null, ['bypass_shell' => false]);
|
|
||||||
if (is_resource($proc)) proc_close($proc);
|
|
||||||
} else {
|
|
||||||
exec("{$cmd} &");
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode(['ok' => true, 'deploying' => true, 'ref' => $ref]);
|
echo json_encode(['ok' => true, 'deploying' => true, 'ref' => $ref]);
|
||||||
|
|||||||
Reference in New Issue
Block a user