-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #7
Develop #7
Changes from all commits
2462642
ab2c456
6d7ce75
92564ed
eea85cf
65fc6ab
886119f
682ad1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
maria -k host.key -b 127.0.0.1:2200 -w async run_socket:app |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,87 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import sys | ||
import argparse | ||
|
||
|
||
def populate_argument_parser(parser): | ||
parser.add_argument("-b", "--bind", default="127.0.0.1:2200", dest="bind", | ||
help="bind host:port") | ||
parser.add_argument("-k", "--key", default="host.key", dest="host_key_path", | ||
help="key file path") | ||
parser.add_argument("-w", "--worker", default="sync", dest="worker", | ||
help="worker async(gevent), sync(socketserver)") | ||
parser.add_argument("--git-path", default="/usr/bin", dest="git_path", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同理 |
||
help="git command path") | ||
parser.add_argument("--repo-path", default="", dest="project_root", | ||
help="git repository root path") | ||
parser.add_argument("--debug", default=False, dest="debug", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个参数有用么? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. debug吗? 在init_log 里面用过一次 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
action="store_true", | ||
help="debug") | ||
parser.add_argument("--log-file", default="./maria.log", dest="log_file", | ||
help="log file path") | ||
parser.add_argument("--auth-timeout", default=20, dest="auth_timeout", | ||
type=int, | ||
help="auth timeout") | ||
parser.add_argument("--check-timeout", default=10, dest="check_timeout", | ||
type=int, | ||
help="check timeout") | ||
parser.add_argument("--select-timeout", default=10, dest="select_timeout", | ||
type=int, | ||
help="select timeout") | ||
|
||
|
||
class Config(object): | ||
|
||
def __init__(self): | ||
self.debug = False | ||
self.log_file = '/tmp/maria.log' | ||
self.host_key = '' | ||
def __init__(self, usage=None, prog=None): | ||
self.usage = usage | ||
self.prog = prog or os.path.basename(sys.argv[0]) | ||
self.host_key = None | ||
|
||
self.bind = '0.0.0.0:2200' | ||
self.host_key_path = 'host.key' | ||
self.worker = 'sync' | ||
self.git_path = '/usr/bin' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个默认应该是指定 git 命令的地方,给个 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. develop分支 gssh.py 改成了 command 加上路径 默认如果是 git 或者是 /usr/bin/git,不是执行不了了吗? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 执行不了指的是什么?没有理解。。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/CMGS/maria/blob/develop/maria/gssh.py#L111-L119 他说这里,是想要拼接git命令,不过似乎都没返回 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯。是这个意思。现在 gssh.py 里面 check_git_command 的处理方式是把 git_path 拼接到commmand[0] 前头了。不用返回command,它保存在command[0]里头了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 要不然就先去掉 git_path 这个选项吧,或者就先这样吧 |
||
self.project_root = '' | ||
self.debug = False | ||
self.log_file = './maria.log' | ||
self.auth_timeout = 20 | ||
self.check_timeout = 10 | ||
self.select_timeout = 10 | ||
self.host = '0.0.0.0' | ||
self.port = 2200 | ||
self.worker = '' | ||
self.project_root = '' | ||
self.git_path = '' | ||
self._ = None | ||
|
||
def parser(self, args): | ||
|
||
# set the config options by args | ||
def load_options(self, args): | ||
for key in dir(args): | ||
if key.startswith('_'): | ||
if key.startswith('_') or key == 'apps': | ||
continue | ||
new_conf = getattr(args, key) | ||
orig_conf = getattr(self, key, None) | ||
if orig_conf is None or orig_conf == new_conf: | ||
continue | ||
setattr(self, key, new_conf) | ||
|
||
# construct a ArgumentParser | ||
def parse(self): | ||
parser = argparse.ArgumentParser( | ||
prog = self.prog, | ||
usage = self.usage, | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
populate_argument_parser(parser) | ||
parser.add_argument("apps", nargs="*", help=argparse.SUPPRESS) | ||
return parser | ||
|
||
# return (host, port) | ||
def get_addr(self): | ||
addr = self.bind.split(':') | ||
if len(addr) is not 2: | ||
raise ValueError('Unrecognized argument value: "%s"' % args.bind) | ||
return (addr[0], int(addr[1])) | ||
|
||
def get(self, key): | ||
if key not in self: | ||
raise AttributeError("No configuration setting for: %s" % key) | ||
return settings.__getattribute__(self, key) | ||
|
||
|
||
config = Config() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
|
||
class WorkerClass(object): | ||
|
||
def __init__(self, addr, app): | ||
self.addr = addr | ||
self.app = app | ||
self.logger = logging.getLogger(self.__class__.__name__) | ||
|
||
def run(self): | ||
raise NotImplementedError() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 - | ||
|
||
try: | ||
from gevent.monkey import patch_all | ||
patch_all(subprocess=False, aggressive=False) | ||
from gevent.server import StreamServer | ||
except ImportError: | ||
raise RuntimeError("You need install gevent") | ||
|
||
from maria.worker.base import WorkerClass | ||
|
||
|
||
class GeventServer(WorkerClass): | ||
|
||
def run(self): | ||
server = StreamServer(self.addr, self.app) | ||
try: | ||
self.logger.info('Maria System Start at %s:%s' % self.addr) | ||
server.serve_forever() | ||
except KeyboardInterrupt: | ||
self.logger.info('Maria System Stopped') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 - | ||
|
||
from SocketServer import TCPServer | ||
from maria.worker.base import WorkerClass | ||
|
||
|
||
class SocketServer(WorkerClass): | ||
|
||
def run(self): | ||
server = TCPServer(self.addr, self.app) | ||
try: | ||
self.logger.info('Maria System Start at %s:%s' % self.addr) | ||
server.serve_forever() | ||
except KeyboardInterrupt: | ||
self.logger.info('Maria System Stopped') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
git_bare=$1 | ||
|
||
if [ -d $git_bare ] | ||
then | ||
exit 1 | ||
fi | ||
|
||
mkdir $git_bare | ||
cd $git_bare | ||
git init --bare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paramiko 的 log 能否都统一输出到 logging ,然后输出文件与否由 logging 的配置决定? cc @CMGS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以的,直接上报到logging.root