1
0

main.py 912 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from configure import configure, conf
  2. import os
  3. import logging
  4. import threading
  5. env_dict = os.environ
  6. hblog_conf = env_dict.get("hblog_conf")
  7. if hblog_conf is None:
  8. logging.info("Configure file ./etc/conf.json")
  9. configure("./etc/conf.json")
  10. else:
  11. logging.info(f"Configure file {hblog_conf}")
  12. configure(hblog_conf)
  13. from app import HBlogFlask
  14. from waitress import serve
  15. app = HBlogFlask(__name__)
  16. app.register_all_blueprint()
  17. from sql.cache import restart_clear_cache
  18. from sql.cache_refresh import refresh
  19. restart_clear_cache() # 清理缓存
  20. class FirstRefresh(threading.Thread):
  21. def run(self):
  22. refresh()
  23. first_refresh_th = FirstRefresh()
  24. first_refresh_th.start()
  25. refresh_th = threading.Timer(conf["CACHE_REFRESH_INTERVAL"], refresh)
  26. refresh_th.start()
  27. if __name__ == '__main__':
  28. logging.info("Server start on 127.0.0.1:8080")
  29. serve(app, host='0.0.0.0', port="8080")