2021SC@SDUSC
目录
前言
libsearpc是rpc框架,而libevhtp是事件通知框架,两者的作用都是使客户端能够调用到所需要的服务,且都在seafile server中被调用,因此首先分析seafile server中相关代码
- rpc框架:远程过程调用协议,使客户端能够通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的思想
- libevhtp:提供http api,从而搭建http服务器
Seafile-server
Seafile的服务器核心。提供RPC给seahub、提供http api给桌面应用。
源码分析
ci/run.py
对seafile-server运行所需要的各部分组件进行部署与安装,包括libsearpc、libevhtp、ccnetserver等
...
@lru_cache()
def get_branch_json_file():
url = '<https://raw.githubusercontent.com/haiwen/seafile-test-deploy/master/branches.json>'
return requests.get(url).json()
def get_project_branch(project, default_branch='master'):
travis_branch = os.environ.get('TRAVIS_BRANCH', 'master')
if project.name == 'seafile-server':
return travis_branch
conf = get_branch_json_file()
return conf.get(travis_branch, {}).get(project.name, default_branch)
class Project(object):
def __init__(self, name):
self.name = name
self.version = ''
@property
def url(self):
return '<https://www.github.com/haiwen/{}.git>'.format(self.name)
@property
def projectdir(self):
return join(TOPDIR, self.name)
def branch(self):
return get_project_branch(self)
def clone(self):
if exists(self.name):
with cd(self.name):
shell('git fetch origin --tags')
else:
shell(
'git clone --depth=1 --branch {} {}'.
format(self.branch(), self.url)
)
@chdir
def compile_and_install(self):
cmds = [
'./autogen.sh',
'./configure --prefix={}'.format(PREFIX),
'make -j{} V=0'.format(num_jobs()),
'make install',
]
for cmd in cmds:
shell(cmd)
@chdir
def use_branch(self, branch):
shell('git checkout {}'.format(branch))
class Libsearpc(Project):
def __init__(self):
super(Libsearpc, self).__init__('libsearpc')
def branch(self):
return 'master'
...
class Libevhtp(Project):
def __init__(self):
super(Libevhtp, self).__init__('libevhtp')
def branch(self):
return 'master'
@chdir
def compile_and_install(sel