Is it possible to start the docker container of the appwrite functions manually? My use case: I have several functions (20+) which don't have a timeout, so they are always up and running for quick responses. But in the case that I restart my server, the functions will be slow on the first run.
I thought I could simply use the command
docker start <project-id>-<deployment-id>
But the docker containers of the appwrite functions aren't restartable as far as I can tell.
Do I need to trigger the 20+ endpoints using a REST request, in order to get all the functions up and running or is there a more elegant way?
My aim is, that the appwrite functions are always highly responsive, even after a restart.
The starting process of a function is inside the Appwrite **executor **container
You can post a rest request to it http://appwrite-executor/v1/execution
from a custom-made-by-you container that will have to be in the appwrite
network, with the necessary data. This can become tricky real fast.
You can find more details here: https://github.com/appwrite/appwrite/blob/master/app/executor.php#L458
For you use-case, you can try one of the following approaches
Increase function threshold time
You can just increase the value of _APP_FUNCTIONS_INACTIVE_THRESHOLD
to lets say 24hours in seconds.
Doing so will increase your function timeline and it each function will consume only RAM when it is on idle mode.
See more here: https://appwrite.io/docs/environment-variables#functions
Gather functions together If you don't want to have to many function keep running around, then you can encapsulate the logic of few function into one, then you can add another variable to know which inner-function you want to run.
Keep alive If you want to keep the threshold to be in a small value, or you don't want to change it. you can create another function, then, let be trigger by CRON job once a hour.
This function will call all the function with a special parameter - keep_alive for example - and any of your function when they will see the keep_alive
parameter will just return res.json
success.
This way you'll make sure that your function will stay "alive".
With this method you also be able to quickly to start all the function, All you need to do is to just execute the new one.
In that case I will probably choose the keep alive variant. I will just trigger that function on start up. Thanks for the hints and tips 🙂
[SOLVED] How to keep runtime container alive (for higher responsiveness)?
Recommended threads
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- HTTP POST to function returning "No Appw...
Hi everyone, I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNC...
- Can't add dart 3.5 runtime
Modified the `.env` to enable dart 3.5 runtime on my self-hosted instance but still can't find the runtime when creating a new function. I manually pulled the i...