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