1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Small update, might work

This commit is contained in:
Steffo 2018-09-19 18:28:40 +02:00
parent 5e83618ea1
commit 092d286a56

16
bots.py
View file

@ -14,10 +14,10 @@ os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(mes
coloredlogs.install(level="DEBUG", logger=logger) coloredlogs.install(level="DEBUG", logger=logger)
discord_telegram_pipe = multiprocessing.Pipe() discord_telegram_pipe = multiprocessing.Pipe()
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True) discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],))
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True) telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],))
reddit = multiprocessing.Process(target=redditbot.process, daemon=True) reddit = multiprocessing.Process(target=redditbot.process)
stats = multiprocessing.Process(target=statsupdate.process, daemon=True) stats = multiprocessing.Process(target=statsupdate.process)
if __name__ == "__main__": if __name__ == "__main__":
logger.info("Starting Discord Bot process...") logger.info("Starting Discord Bot process...")
@ -34,24 +34,24 @@ if __name__ == "__main__":
logger.warning(f"Discord Bot exited with {discord.exitcode}") logger.warning(f"Discord Bot exited with {discord.exitcode}")
del discord del discord
logger.info("Restarting Discord Bot process...") logger.info("Restarting Discord Bot process...")
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True) discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],))
discord.start() discord.start()
if telegram.exitcode is not None: if telegram.exitcode is not None:
logger.warning(f"Telegram Bot exited with {telegram.exitcode}") logger.warning(f"Telegram Bot exited with {telegram.exitcode}")
del telegram del telegram
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True) telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],))
logger.info("Restarting Telegram Bot process...") logger.info("Restarting Telegram Bot process...")
telegram.start() telegram.start()
if reddit.exitcode is not None: if reddit.exitcode is not None:
logger.warning(f"Reddit Bot exited with {reddit.exitcode}") logger.warning(f"Reddit Bot exited with {reddit.exitcode}")
del reddit del reddit
reddit = multiprocessing.Process(target=redditbot.process, daemon=True) reddit = multiprocessing.Process(target=redditbot.process)
logger.info("Restarting Reddit Bot process...") logger.info("Restarting Reddit Bot process...")
reddit.start() reddit.start()
if stats.exitcode is not None: if stats.exitcode is not None:
logger.warning(f"StatsUpdater exited with {stats.exitcode}") logger.warning(f"StatsUpdater exited with {stats.exitcode}")
del stats del stats
stats = multiprocessing.Process(target=statsupdate.process, daemon=True) stats = multiprocessing.Process(target=statsupdate.process)
logger.info("Restarting StatsUpdate process...") logger.info("Restarting StatsUpdate process...")
stats.start() stats.start()
time.sleep(10) time.sleep(10)