1 Star 0 Fork 37

tomtsang/auto_release

forked from awakenjoys/auto_release 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tasks.py 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
awakenjoys 提交于 2014-02-13 14:25 . auto release sourcode
# -*- coding:utf8 -*-
from celery import Celery
import os
import xmlrpclib
import tornado.httpclient
from celery.task.http import URL
app = Celery('task', backend='redis://192.168.5.13:6379/0', broker='redis://192.168.5.13:6379/0')
#------------------------------------------------------------------------------
#版本发布任务
@app.task
def release_version(server_ip, v_filename, local_path, dest_path, process_name):
#解压版本zip包到/tmp目录中
unzip_cmd = "unzip -o %s -d /tmp/" % v_filename
os.system(unzip_cmd)
#发布版本到指定的服务器
rsync_cmd = 'rsync -avz -e ssh --exclude "init.properties" --exclude "jdbc.properties" --exclude "redis.properties" %s root@%s:%s --delete' % (local_path, server_ip, dest_path)
print rsync_cmd
os.system(rsync_cmd)
#------------------------------------------------------------------------------
#服务进程管理任务
@app.task
def services_manager(server_ip, active, process_name):
rpcaddr = 'http://%s:9001/RPC2' % server_ip
server = xmlrpclib.Server(rpcaddr)
if active == "start":
server.supervisor.startProcess(process_name)
if active == "stop":
server.supervisor.stopProcess(process_name)
if active == "restart":
server.supervisor.stopProcess(process_name)
server.supervisor.startProcess(process_name)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/tomtsang/auto_release.git
[email protected]:tomtsang/auto_release.git
tomtsang
auto_release
auto_release
master

搜索帮助