mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Bug fixes
This commit is contained in:
parent
3e325afb61
commit
3b6174b5a7
1 changed files with 6 additions and 41 deletions
|
|
@ -40,7 +40,6 @@ Server::setResource('execute', function () {
|
||||||
string $jwt = null,
|
string $jwt = null,
|
||||||
Client $statsd
|
Client $statsd
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$user ??= new Document();
|
$user ??= new Document();
|
||||||
$functionId = $function->getId();
|
$functionId = $function->getId();
|
||||||
$deploymentId = $function->getAttribute('deployment', '');
|
$deploymentId = $function->getAttribute('deployment', '');
|
||||||
|
|
@ -93,48 +92,13 @@ Server::setResource('execute', function () {
|
||||||
'search' => implode(' ', [$functionId, $executionId]),
|
'search' => implode(' ', [$functionId, $executionId]),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
if ($execution->isEmpty()) {
|
// TODO: @Meldiron Trigger executions.create event here
|
||||||
throw new Exception('Failed to create or read execution');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$execution->setAttribute('status', 'processing');
|
|
||||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
|
||||||
|
|
||||||
if ($build->getAttribute('status') !== 'ready') {
|
|
||||||
throw new Exception('Build not ready');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Check if runtime is supported */
|
|
||||||
$runtimes = Config::getParam('runtimes', []);
|
|
||||||
|
|
||||||
if (!\array_key_exists($function->getAttribute('runtime'), $runtimes)) {
|
|
||||||
throw new Exception('Runtime "' . $function->getAttribute('runtime', '') . '" is not supported');
|
|
||||||
}
|
|
||||||
|
|
||||||
$runtime = $runtimes[$function->getAttribute('runtime')];
|
|
||||||
|
|
||||||
/** Create execution or update execution status */
|
|
||||||
$execution = $dbForProject->getDocument('executions', $executionId ?? '');
|
|
||||||
if ($execution->isEmpty()) {
|
|
||||||
$executionId = ID::unique();
|
|
||||||
$execution = $dbForProject->createDocument('executions', new Document([
|
|
||||||
'$id' => $executionId,
|
|
||||||
'$permissions' => $user->isEmpty() ? [] : [Permission::read(Role::user($user->getId()))],
|
|
||||||
'functionId' => $functionId,
|
|
||||||
'deploymentId' => $deploymentId,
|
|
||||||
'trigger' => $trigger,
|
|
||||||
'status' => 'waiting',
|
|
||||||
'statusCode' => 0,
|
|
||||||
'response' => '',
|
|
||||||
'stderr' => '',
|
|
||||||
'duration' => 0.0,
|
|
||||||
'search' => implode(' ', [$functionId, $executionId]),
|
|
||||||
]));
|
|
||||||
|
|
||||||
if ($execution->isEmpty()) {
|
if ($execution->isEmpty()) {
|
||||||
throw new Exception('Failed to create or read execution');
|
throw new Exception('Failed to create or read execution');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$execution->setAttribute('status', 'processing');
|
$execution->setAttribute('status', 'processing');
|
||||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
||||||
|
|
||||||
|
|
@ -311,7 +275,7 @@ $server->job()
|
||||||
project: $project,
|
project: $project,
|
||||||
function: $function,
|
function: $function,
|
||||||
queueForFunctions: $queueForFunctions,
|
queueForFunctions: $queueForFunctions,
|
||||||
trigger: $type,
|
trigger: 'event',
|
||||||
event: $events[0],
|
event: $events[0],
|
||||||
eventData: $eventData,
|
eventData: $eventData,
|
||||||
user: $user,
|
user: $user,
|
||||||
|
|
@ -322,6 +286,7 @@ $server->job()
|
||||||
Console::success('Triggered function: ' . $events[0]);
|
Console::success('Triggered function: ' . $events[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -337,7 +302,7 @@ $server->job()
|
||||||
function: $function,
|
function: $function,
|
||||||
dbForProject: $dbForProject,
|
dbForProject: $dbForProject,
|
||||||
queueForFunctions: $queueForFunctions,
|
queueForFunctions: $queueForFunctions,
|
||||||
trigger: $type,
|
trigger: 'http',
|
||||||
executionId: $execution->getId(),
|
executionId: $execution->getId(),
|
||||||
event: null,
|
event: null,
|
||||||
eventData: null,
|
eventData: null,
|
||||||
|
|
@ -353,7 +318,7 @@ $server->job()
|
||||||
function: $function,
|
function: $function,
|
||||||
dbForProject: $dbForProject,
|
dbForProject: $dbForProject,
|
||||||
queueForFunctions: $queueForFunctions,
|
queueForFunctions: $queueForFunctions,
|
||||||
trigger: $type,
|
trigger: 'schedule',
|
||||||
executionId: null,
|
executionId: null,
|
||||||
event: null,
|
event: null,
|
||||||
eventData: null,
|
eventData: null,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue