runpod serverless start.sh issue

Hello, I'm having an issue with my Dockerfile and start.sh script. At the end of my Dockerfile, I have ENTRYPOINT ["./start.sh"] which runs the start.sh script. This script starts the comfyui server and then runs rp_handler at the end. When the API is called for the first time, the docker image initializes and the start.sh script successfully starts the comfyui server. However, on the second API call, it seems to skip the contents of start.sh and directly runs rp_handler.py, causing issues. Here's the content of my start.sh file: #!/usr/bin/env bash echo "Worker Initiated" echo "Symlinking files from Network Volume" if [ -L "/workspace/ComfyUI" ]; then echo "/workspace/ComfyUI is already a symlink" else ln -s /runpod-volume/ComfyUI /workspace fi if [ -L "/workspace/comfyui-venv" ]; then echo "/workspace/comfyui-venv is already a symlink" else ln -s /runpod-volume/comfyui-venv /workspace fi echo "Starting ComfyUI API" if [ -d "comfyui-venv" ]; then echo "Virtual environment directory exists" else echo "Virtual environment directory does not exist" exit 1 fi if [ -f "comfyui-venv/bin/activate" ]; then echo "Activate script exists" else echo "Activate script does not exist" exit 1 fi source comfyui-venv/bin/activate if [[ $VIRTUAL_ENV == "/workspace/comfyui-venv" ]]; then echo "Virtual environment activated successfully" else echo "Failed to activate virtual environment" echo "Content of the activate script:" cat comfyui-venv/bin/activate exit 1 fi export HF_HOME="/workspace" cd /workspace/ComfyUI && python main.py --port 3000 & deactivate echo "Starting RunPod Handler" python -u /workspace/rp_handler.py
7 Replies
digigoblin
digigoblin8mo ago
If you enable flash boot this will happen. How does it cause issues by not running the start.sh script on every request?
streamize
streamizeOP8mo ago
In the start.sh script, it first hosts the comfyui server on port 3000, and then rp_handler.py communicates with the API using that hosted port 3000. I am not using flashboot.
streamize
streamizeOP8mo ago
I implemented it using the method described in the https://github.com/ashleykleynhans/runpod-worker-comfyui repository.
GitHub
GitHub - ashleykleynhans/runpod-worker-comfyui: RunPod Serverless W...
RunPod Serverless Worker for the ComfyUI Stable Diffusion API - ashleykleynhans/runpod-worker-comfyui
digigoblin
digigoblin8mo ago
I use ComfyUI the same way and it works fine for me Mine has flashboot enabled though, but that shouldn't really make a difference, it just reduces cold start times.
streamize
streamizeOP8mo ago
This image shows the runpod serverless endpoint configuration. hmm.... I cant find reason haha
digigoblin
digigoblin8mo ago
What is the actual issue you are having? Do you have an error or something?
streamize
streamizeOP8mo ago
Upon further investigation, I found that an error occurs on line 244 of the rp_handler.py file that I attached. Line 244 is the code responsible for saving the generated image from the comfyui API. The first runpod serverless call, where the Docker image is initialized and start.sh is executed, works as expected. However, from the second call onwards, after the Docker image has been initialized, it seems that comfyui is not generating the images. I'm not sure why this issue is occurring, but starting from the second call, comfyui does not create images in the temp directory. (It appears that the image generation task is not being performed at all, even though the comfyui server is running.) Lastly, there's a part that I don't understand. When all instances of runpod serverless are terminated and an instance is started, start.sh is not executed, but I don't understand why the comfyui server port is still active. It doesn't seem to be starting up properly. The attached image is a screenshot of the logs. This image represents a case where everything is processed correctly (when the Docker image is initialized for the first time and start.sh is executed successfully). This is an image capturing the logs of a failed case. (It is executed without start.sh being run.)
Want results from more Discord servers?
Add your server