S
S
Stepan Sidorov2020-07-14 20:46:34
Python
Stepan Sidorov, 2020-07-14 20:46:34

Why does google cloud stop a python program?

Hello.
I am using google cloud for my telegram bot. And I thought that if you run the bot on the google cloud, and then just leave it turned on, then the program will work all the time.
But alas, no, after an hour and a half, the program simply closes, and it is not in the processes either (python).
I checked the program at home, bot.polling()I put it in while True, and even if something is wrong with the bot, the process does not end.
Am I doing something wrong, or is google (or debian) really just ending processes somehow?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SKEPTIC, 2020-07-14
@Stepan47

You need to install screen to run in the background.
sudo apt-get install screen
Next, write to the console
screen
, press the enter button 2-3 times and start the bot, then just close ssh or whatever you have there. everything should work.
There is also a possibility that your program is getting exceptions. Try try except, at least without specific exceptions, and log it to a file.
Tipo

try:
////твой код

except Exception as e:
    file = open('log.txt', 'a')
    file.write(str(e))

G
GavriKos, 2020-07-14
@GavriKos

I checked the program myself, I set bot.polling() to while True, and even if something is wrong with the bot, the process does not end.

Not sure if this is enough. Arrange logs, wrap in tri-catch, monitor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question