Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # encoding:utf-8
  2. import os
  3. import signal
  4. import sys
  5. from channel import channel_factory
  6. from common.log import logger
  7. from config import conf, load_config
  8. from plugins import *
  9. def sigterm_handler_wrap(_signo):
  10. old_handler = signal.getsignal(_signo)
  11. def func(_signo, _stack_frame):
  12. logger.info("signal {} received, exiting...".format(_signo))
  13. conf().save_user_datas()
  14. if callable(old_handler): # check old_handler
  15. return old_handler(_signo, _stack_frame)
  16. sys.exit(0)
  17. signal.signal(_signo, func)
  18. def run():
  19. try:
  20. # load config
  21. load_config()
  22. # ctrl + c
  23. sigterm_handler_wrap(signal.SIGINT)
  24. # kill signal
  25. sigterm_handler_wrap(signal.SIGTERM)
  26. # create channel
  27. channel_name = conf().get("channel_type", "wx")
  28. if "--cmd" in sys.argv:
  29. channel_name = "terminal"
  30. if channel_name == "wxy":
  31. os.environ["WECHATY_LOG"] = "warn"
  32. # os.environ['WECHATY_PUPPET_SERVICE_ENDPOINT'] = '127.0.0.1:9001'
  33. channel = channel_factory.create_channel(channel_name)
  34. if channel_name in ["wx", "wxy", "terminal", "wechatmp", "wechatmp_service", "wechatcom_app", "wework"]:
  35. PluginManager().load_plugins()
  36. # startup channel
  37. channel.startup()
  38. except Exception as e:
  39. logger.error("App startup failed!")
  40. logger.exception(e)
  41. if __name__ == "__main__":
  42. run()