-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhypernode-deploy.php
More file actions
69 lines (55 loc) · 2.05 KB
/
hypernode-deploy.php
File metadata and controls
69 lines (55 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Hypernode\Deploy;
use Exception;
use Symfony\Component\Process\Exception\RuntimeException;
use Symfony\Component\Process\Process;
\define('WORKING_DIR', getcwd());
\define('APPLICATION_ROOT', \dirname(__DIR__));
// Allows to specify a custom autoload path to avoid overriding Hipex deploy packages
// when the same packages are used by your application and Hipex Deploy.
if (getenv('DEPLOY_AUTOLOAD_PATH') !== false) {
$customAutoLoadPath = getenv('DEPLOY_AUTOLOAD_PATH');
if (file_exists($customAutoLoadPath)) {
require_once $customAutoLoadPath;
}
}
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require_once APPLICATION_ROOT . '/vendor/autoload.php';
if (!array_key_exists('Deployer\\', $loader->getPrefixesPsr4())) {
$loader->setPsr4('Deployer\\', APPLICATION_ROOT . '/vendor/deployer/deployer/src');
require_once APPLICATION_ROOT . '/vendor/deployer/deployer/src/functions.php';
require_once APPLICATION_ROOT . '/vendor/deployer/deployer/src/Support/helpers.php';
}
$calledBinary = basename($argv[0]);
if ($calledBinary === 'hipex-deploy') {
fwrite(STDERR, "\n\e[33mDEPRECATED: Command 'hipex-deploy' was called, please call 'hypernode-deploy'. This fallback will be removed in future versions!\e[39m\n\n");
}
if (!getenv('SSH_AUTH_SOCK')) {
$process = Process::fromShellCommandline(sprintf(
'eval "$(ssh-agent -s) " && %s %s',
PHP_BINARY,
implode(' ', array_map('escapeshellarg', $argv))
));
try {
$process->setTty(true);
} catch (RuntimeException $e) {
// This is expected in some situation and does not impose problems
}
$process->setTimeout(0);
$process->run(function ($type, $buffer) {
if ($type === Process::ERR) {
fwrite(STDERR, $buffer);
} else {
fwrite(STDOUT, $buffer);
}
});
exit($process->getExitCode());
}
$app = new Bootstrap();
try {
exit($app->run());
} catch (Exception $e) {
echo 'Build failed ' . $e->getMessage();
echo $e;
exit($e->getCode() ?? 1);
}