You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.py 1.0KB

1 vuosi sitten
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # encoding:utf-8
  2. import os
  3. from config import conf, load_config
  4. from channel import channel_factory
  5. from common.log import logger
  6. from plugins import *
  7. import signal
  8. import sys
  9. def sigterm_handler(_signo, _stack_frame):
  10. conf().save_user_datas()
  11. sys.exit(0)
  12. def run():
  13. try:
  14. # load config
  15. load_config()
  16. # ctrl + c
  17. signal.signal(signal.SIGINT, sigterm_handler)
  18. # kill signal
  19. signal.signal(signal.SIGTERM, sigterm_handler)
  20. # create channel
  21. channel_name=conf().get('channel_type', 'wx')
  22. if channel_name == 'wxy':
  23. os.environ['WECHATY_LOG']="warn"
  24. # os.environ['WECHATY_PUPPET_SERVICE_ENDPOINT'] = '127.0.0.1:9001'
  25. channel = channel_factory.create_channel(channel_name)
  26. if channel_name in ['wx','wxy','wechatmp']:
  27. PluginManager().load_plugins()
  28. # startup channel
  29. channel.startup()
  30. except Exception as e:
  31. logger.error("App startup failed!")
  32. logger.exception(e)
  33. if __name__ == '__main__':
  34. run()