- I started an EC2 instance with a user data script.
- This script initiates my application.
- A graceful shutdown is implemented in the application (an HTTP request is sent upon receiving SIGTERM).
- I stop/reboot/terminate the EC2 instance. Expected: The application receives a SIGTERM signal and makes a request. Actual: The application does not receive any SIGTERM signal.
It seems like processes started from the user data script do not receive a SIGTERM signal.
What I've tried:
- Starting the process in the foreground from user data(python3 /app.py).
- Starting the process in the background from user data (python3 /app.py &).
- Starting the process in the background with nohup from user data (nohup python3 /app.py > /dev/null 2>&1 &). None of these methods work.
What works:
- Starting the process in the background via SSH (ssh 'nohup python3 /app.py > /dev/null 2>&1 &').