#!/usr/bin/env python # -*- coding: utf-8 -*- # @File : config.py # @Author: becivells #@Contact : becivells@gmail.com # @Date : 2017/10/19 #@Software : PyCharm # @Desc : import os from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker basedir = os.path.abspath(os.path.dirname(__file__)) dbdir = basedir + os.sep + 'db' HOST = '0.0.0.0' PORT = 21332 DEBUG = False #True or False #允许git server地址访问 GIT_SERVER = [ #localhost '127.0.0.1', '123.206.177.125', '123.206.116.149' ] #访问的路径 SYNC_PATH = 'hookssync' ##如果token不存在路径访问正确那么访问时频繁更新配置间隔的时间 CONF_UPDATE_TIME = 30 #允许执行命令时的路径 PATH_WHITE_LIST = [ # 匹配所有 '.*', # /app/web/test '^/app/web/.*', # /app/web/tests '^/var/www/html/.*', '/www/wwwroot/.*' ] SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess' SQLALCHEMY_DATABASE_SQLITE_URI = "mysql+pymysql://root:password@localhost:3306/webhook?charset=utf8" # os.environ.get('DATABASE_URL') or \ # 'sqlite:///' + os.path.join(dbdir, 'app.db') SQLALCHEMY_TRACK_MODIFICATIONS = False engine = create_engine(SQLALCHEMY_DATABASE_SQLITE_URI) session_class = sessionmaker(bind=engine) #允许在webhooks执行时执行的命令 使用正则表达式进行匹配 EXEC_WHITE_LIST = [ # 匹配所有 '.*', # git pull origin master '^git pull \w+ \w+$', # git fetch origin master && git reset --hard origin/master '^git fetch \w+ \w+ && git reset --hard \w+/\w+$', # git pull origin master && supervisorctl restart webhooks '^git pull \w+ \w+ && supervisorctl restart \w+$', # git fetch origin master && git reset --hard origin/master && supervisorctl restart webhooks '^git fetch \w+ \w+ && git reset --hard \w+/\w+ && supervisorctl restart \w+$' ] repo = { "9901b6deb47111e7b832704d7b885ead":{ "name":"hneccp", "path":"/app/web/www.hneccp.com/", "ip":['127.0.0.1','123.206.177.125'], "cmd":'git pull origin master', "user":'apache', 'interval':10 }, } # repo = { # "9901b6deb47111e7b832704d7b885ead":{ # "name":"fanghuishop", # "path":"/app/web/fanghuishop", # "ip":['127.0.0.1','123.206.177.125'], # "cmd":'git fetch origin master && git reset --hard origin/master', # "user":'apache', # 'interval':3 # } # }