-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.py
30 lines (25 loc) · 820 Bytes
/
loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from managers import logger
from pathlib import Path
import os
import signal
import subprocess
main_path = Path(__file__).resolve().parent
paths = [
Path(main_path, "bots", "vk"),
Path(main_path, "bots", "tg"),
Path(main_path, "bots", "ds")
]
processes = []
def start() -> None: # Somehow I’ll make the launch of bots more efficient... But right now it’s like this
try:
for path in paths:
logger.info(f"Checking and installing dependencies \"{path}\"...")
subprocess.call(f"cd {path} && poetry install", shell = True)
processes.append(subprocess.Popen(f"cd {path} && poetry run python bot.py {main_path}", shell = True))
for process in processes:
process.wait()
except KeyboardInterrupt:
for process in processes:
process.send_signal(signal.SIGINT)
if __name__ == "__main__":
start()