Avatar ·

Auto-loading .py script on Linux

📁 Advanced Python Topics, python3, bots, work

Hello everyone, I bought an Orangepi to make a server for Telegram bots. I need the bots to start automatically after the device reboots. I tried many methods, but only one helped somewhat: through sudo crontab -e I wrote this:

@reboot python3 /home/orangepi/bots/weather_bot/weather_bot.py &@reboot python3 /home/orangepi/bots/echo_bot/main.py &

It seemed to help, I thought, but after a couple of hours the bots stopped working. And it kept happening: when I rebooted the device, they seemed to work, but after a couple of hours all bots become inactive. What should I do?

Avatar ·

There are several different ways to separate Django configurations on the internet, but the best one in my opinion is separation through modules and DJANGO_SETTINGS_MODULE.

Starting Django begins with reading the Python module with settings, and the name of the required module must be specified in the environment variable DJANGO_SETTINGS_MODULE — without it Django simply won't start. To make life easier for developers, the django-admin startproject command automatically sets DJANGO_SETTINGS_MODULE with a value like yourproject.settings in the files manage.py, wsgi.py and asgi.py. Thus, by changing the value of DJANGO_SETTINGS_MODULE, we can switch between different settings files.

To

Log in to leave an answer

Blogs