config.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # @File : config.py
  4. # @Author: becivells
  5. #@Contact : becivells@gmail.com
  6. # @Date : 2017/10/19
  7. #@Software : PyCharm
  8. # @Desc :
  9. import os
  10. from sqlalchemy import create_engine
  11. from sqlalchemy.orm import sessionmaker
  12. basedir = os.path.abspath(os.path.dirname(__file__))
  13. dbdir = basedir + os.sep + 'db'
  14. HOST = '0.0.0.0'
  15. PORT = 21332
  16. DEBUG = False #True or False
  17. #允许git server地址访问
  18. GIT_SERVER = [
  19. #localhost
  20. '127.0.0.1',
  21. '123.206.177.125',
  22. '123.206.116.149'
  23. ]
  24. #访问的路径
  25. SYNC_PATH = 'hookssync'
  26. ##如果token不存在路径访问正确那么访问时频繁更新配置间隔的时间
  27. CONF_UPDATE_TIME = 30
  28. #允许执行命令时的路径
  29. PATH_WHITE_LIST = [
  30. # 匹配所有
  31. '.*',
  32. # /app/web/test
  33. '^/app/web/.*',
  34. # /app/web/tests
  35. '^/var/www/html/.*',
  36. '/www/wwwroot/.*'
  37. ]
  38. SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
  39. SQLALCHEMY_DATABASE_SQLITE_URI = "mysql+pymysql://root:password@localhost:3306/webhook?charset=utf8"
  40. # os.environ.get('DATABASE_URL') or \
  41. # 'sqlite:///' + os.path.join(dbdir, 'app.db')
  42. SQLALCHEMY_TRACK_MODIFICATIONS = False
  43. engine = create_engine(SQLALCHEMY_DATABASE_SQLITE_URI)
  44. session_class = sessionmaker(bind=engine)
  45. #允许在webhooks执行时执行的命令 使用正则表达式进行匹配
  46. EXEC_WHITE_LIST = [
  47. # 匹配所有
  48. '.*',
  49. # git pull origin master
  50. '^git pull \w+ \w+$',
  51. # git fetch origin master && git reset --hard origin/master
  52. '^git fetch \w+ \w+ && git reset --hard \w+/\w+$',
  53. # git pull origin master && supervisorctl restart webhooks
  54. '^git pull \w+ \w+ && supervisorctl restart \w+$',
  55. # git fetch origin master && git reset --hard origin/master && supervisorctl restart webhooks
  56. '^git fetch \w+ \w+ && git reset --hard \w+/\w+ && supervisorctl restart \w+$'
  57. ]
  58. repo = {
  59. "9901b6deb47111e7b832704d7b885ead":{
  60. "name":"hneccp",
  61. "path":"/app/web/www.hneccp.com/",
  62. "ip":['127.0.0.1','123.206.177.125'],
  63. "cmd":'git pull origin master',
  64. "user":'apache',
  65. 'interval':10
  66. },
  67. }
  68. # repo = {
  69. # "9901b6deb47111e7b832704d7b885ead":{
  70. # "name":"fanghuishop",
  71. # "path":"/app/web/fanghuishop",
  72. # "ip":['127.0.0.1','123.206.177.125'],
  73. # "cmd":'git fetch origin master && git reset --hard origin/master',
  74. # "user":'apache',
  75. # 'interval':3
  76. # }
  77. # }