I have a service that I want to run as a python webserver. The python code generates a FASTapi webserver. When I run the code in a running EC2 instance, the code is running and generates a webserver at port 8080 which I can access.
But I want to start the webserver as soon as I start the EC2 instance.
I put the following bash script in the user data section of launch instance in AWS.
#!/bin/bash
python3 <absolute path of the python file>
But it is not running the python file and starting the webserver.
What am I doing wrong here? Is there anything I am missing? or is there any other way to achieve the same?