* Move default host value from code to env variables
* Add validation for host value
This commit is contained in:
parent
ade4024593
commit
e37d1be6a6
2
.env
2
.env
|
@ -56,7 +56,7 @@ _APP_FUNCTIONS_MEMORY_SWAP=0
|
|||
_APP_FUNCTIONS_INACTIVE_THRESHOLD=60
|
||||
OPEN_RUNTIMES_NETWORK=appwrite_runtimes
|
||||
_APP_EXECUTOR_SECRET=your-secret-key
|
||||
_APP_EXECUTOR_HOST=
|
||||
_APP_EXECUTOR_HOST=http://appwrite-executor/v1
|
||||
_APP_MAINTENANCE_INTERVAL=86400
|
||||
_APP_MAINTENANCE_RETENTION_EXECUTION=1209600
|
||||
_APP_MAINTENANCE_RETENTION_ABUSE=86400
|
||||
|
|
|
@ -185,7 +185,7 @@ ENV _APP_SERVER=swoole \
|
|||
_APP_FUNCTIONS_MEMORY=128 \
|
||||
_APP_FUNCTIONS_MEMORY_SWAP=128 \
|
||||
_APP_EXECUTOR_SECRET=a-random-secret \
|
||||
_APP_EXECUTOR_HOST= \
|
||||
_APP_EXECUTOR_HOST=http://appwrite-executor/v1 \
|
||||
_APP_EXECUTOR_RUNTIME_NETWORK=appwrite_runtimes \
|
||||
_APP_SETUP=self-hosted \
|
||||
_APP_VERSION=$VERSION \
|
||||
|
|
|
@ -938,7 +938,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
]);
|
||||
|
||||
/** Execute function */
|
||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST', 'http://appwrite-executor/v1'));
|
||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||
$executionResponse = [];
|
||||
try {
|
||||
$executionResponse = $executor->createExecution(
|
||||
|
|
|
@ -33,7 +33,7 @@ class BuildsV1 extends Worker
|
|||
}
|
||||
|
||||
public function init(): void {
|
||||
$this->executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST', 'http://appwrite-executor/v1'));
|
||||
$this->executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
|
|
|
@ -368,7 +368,7 @@ class DeletesV1 extends Worker
|
|||
* Request executor to delete all deployment containers
|
||||
*/
|
||||
Console::info("Requesting executor to delete all deployment containers for function " . $functionId);
|
||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST', 'http://appwrite-executor/v1'));
|
||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||
foreach ($deploymentIds as $deploymentId) {
|
||||
try {
|
||||
$executor->deleteRuntime($projectId, $deploymentId);
|
||||
|
@ -420,7 +420,7 @@ class DeletesV1 extends Worker
|
|||
*/
|
||||
Console::info("Requesting executor to delete deployment container for deployment " . $deploymentId);
|
||||
try {
|
||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST', 'http://appwrite-executor/v1'));
|
||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||
$executor->deleteRuntime($projectId, $deploymentId);
|
||||
} catch (Throwable $th) {
|
||||
Console::error($th->getMessage());
|
||||
|
|
|
@ -37,7 +37,7 @@ class FunctionsV1 extends Worker
|
|||
|
||||
public function init(): void
|
||||
{
|
||||
$this->executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST', 'http://appwrite-executor/v1'));
|
||||
$this->executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
|
|
|
@ -18,8 +18,6 @@ class Executor
|
|||
const METHOD_CONNECT = 'CONNECT';
|
||||
const METHOD_TRACE = 'TRACE';
|
||||
|
||||
const DEFAULT_HOST = 'http://appwrite-executor/v1';
|
||||
|
||||
private $endpoint;
|
||||
|
||||
private $selfSigned = false;
|
||||
|
@ -28,14 +26,12 @@ class Executor
|
|||
'content-type' => '',
|
||||
];
|
||||
|
||||
public function __construct(string $endpoint = self::DEFAULT_HOST)
|
||||
public function __construct(string $endpoint)
|
||||
{
|
||||
if (empty($endpoint)) {
|
||||
Console::warning('Undefined Executor host (fallback to ' . self::DEFAULT_HOST . ')');
|
||||
$this->endpoint = self::DEFAULT_HOST;
|
||||
} else {
|
||||
$this->endpoint = $endpoint;
|
||||
if (!filter_var($endpoint, FILTER_VALIDATE_URL)) {
|
||||
throw new Exception('Unsupported endpoint');
|
||||
}
|
||||
$this->endpoint = $endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue