From 2d82ddda07a8b93dd0199f8e2098a4fb30a2631a Mon Sep 17 00:00:00 2001 From: 3err0 Date: Mon, 24 Jun 2019 07:08:40 +0800 Subject: [PATCH] pid file --- config.py | 5 +++-- main.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config.py b/config.py index 5911ae2..1665423 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,7 @@ +pid = '/var/run/bot.pid' bot_token='' -proxy = 'socks5h://socks:pr0xy@109.234.36.187:1080' +proxy = 'socks5h://proxy.addr' zabbix_api = 'http://127.0.0.1/api_jsonrpc.php' zabbix_user = 'api' zabbix_pass = 'pass' -users = ['1234', '5678'] \ No newline at end of file +users = [1234, 5678] \ No newline at end of file diff --git a/main.py b/main.py index 1223f3f..c0b1986 100644 --- a/main.py +++ b/main.py @@ -58,10 +58,11 @@ def handle_file(message): except Exception as e: bot.reply_to(message,e ) -#while True: -# try: -# bot.polling(none_stop=True, interval=0, timeout=10) -# except Exception as e: -# print(e) -# time.sleep(15) -bot.polling(none_stop=True, interval=0, timeout=10) \ No newline at end of file +try: + pid = str(os.getpid()) + pidfile = open(config.pid, 'w') + pidfile.write(pid) + pidfile.close() + bot.polling(none_stop=True, interval=0, timeout=10) +except: + pass \ No newline at end of file