Python script install

Hey guys! If someone have time to explain completely new user - that would be great.

I just need to have python script on a server that will work 24/7 and auto-relaunch if script have an error.
Can somebody just give an instruction how to do it?

Hi there,

The specifics of this answer depend on what the Python script does. Does it run a web service and handle HTTP requests, or is it just something that runs in the background and performs tasks?

Does it require any dependencies to be installed?

Regards,

Keith
Render Support, UTC+10 :australia:

It’s running on the background and basically open links to download pictures from them into Telegram bot. It requiers python libraries

Hi there,

It should be fairly straightforward then.

  1. Create a background worker service.
  2. Set the build command to pip install -r requirements.txt
  3. Set the start command to python my-script.py.

You will need to have your code and requirements.txt pushed to wither GitHub or GitLab

Regards,

Keith
Render Support, UTC+10 :australia:

regarding auto re-launch if there is an error:

running the script with python will not solve this, instead you would use something like supervisord with --nodaemon

http://supervisord.org/running.html

Hi there,

You don’t need this when running on Render. Our control plane will restart the process if it crashes. You do, however, need to make sure your script runs in a loop. Otherwise, it will exit after running through once.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.