f4ls3
As I understood it is possible to create a function execution from the server sdk with an ISO date as the time. Am I wrong to assume that this will execute the function at the given time?
TypeScript
router.post('/database/events/create', async (req, res) => {
const {eventName, service, startTime, endTime, destinations, autoSource} = req.body;
if (!autoSource) return res.status(200).send({success: true});
const capability = (await databases.listDocuments(process.env.APPWRITE_DATABASE_ID ?? '', process.env.APPWRITE_DATABASE_SERVICE ?? '')).documents.find((document) => document.serviceName === service)?.capability;
if (!capability) return res.status(500).send({success: false, message: 'Invalid service'});
const source = (await databases.listDocuments(process.env.APPWRITE_DATABASE_ID ?? '', process.env.APPWRITE_DATABASE_INPUT_DEFINITIONS ?? '')).documents.filter((document) => document.capabilities == capability && document.available == true)[0];
if (!source) return res.status(500).send({success: false, message: 'Invalid source'});
await functions.createExecution(
process.env.APPWRITE_FUNCTIONS_SCHEDULER_ID ?? '',
JSON.stringify(
{
destinations,
source
}
),
false,
'/',
ExecutionMethod.POST,
{
"x-appwrite-request-signature": generateRequestSignature({destinations, source})
},
new Date(startTime).toISOString()
)
.then((res) => {
logger.info(`Scheduled function execution for '${eventName}' at ${startTime} was created`);
// TODO: Update TV Event Document in database to add executionId
// await databases.updateDocument()
})
.catch((err) => logger.error(`Failed to create scheduled function execution for '${eventName}' -> ${err.message}`));
res.status(200).send({success: true});
});
It just creates an execution that runs instantaneously.
TL;DR
Developers are trying to schedule a cloud function to run at a specific time based on an ISO date, but currently, the code they have only creates an execution that runs instantaneously. The issue lies in the scheduling of the function based on the time provided. To schedule the function to run at a given time, developers need to adjust the code to trigger the execution at the specified ISO date successfully. Recommended threads
- 502: Proxy Error after 60 secondes
Every REST request I made in my function automatically abort after 60 secondes and return 502: Proxy Error Appwrite version: 1.5.7 Function runtime: Node 16 Sd...
- Can send phone authentication requests f...
I am running phone authentication on my website and when I try to Send OTP it is going fine when I do it on any browser on PC but when I do it on phone it's giv...
- Docker appwrite not working with domain ...
docker ps -a attached [root@vps1 appwrite]# docker logs appwrite-traefik time="2024-09-16T15:53:21Z" level=info msg="Configuration loaded from flags."