get '/api/auto_publish/publish' => sub{
my $c = shift;
my $env = $c->param('env');
my $app = $c->param('app');
my $ip = $c->param('ip');
my $stderr="";
my $stdout="";
my $XDATE = strftime("%Y%m%d%H%M%S",localtime()); #and info='$app' and ip='$ip'
use DBI;
my %hash=();
my $dbUser='DEVOPS';
my $user="root";
my $passwd="1234567";
my $dbh = DBI->connect("dbi:mysql:database=$dbUser;host=192.168.32.161;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
my $hostSql = qq{select script from publish_info where env='$env' and info='$app' and ip='$ip'};
my $selStmt = $dbh->prepare($hostSql);
print "\$hostSql is $hostSql\n";
$selStmt->execute();
my $script = $selStmt->fetchrow_array(); print "\$script is $script\n";
use Net::SSH::Perl;
my $host="$ip";;
my $user='root';
my $passwd='xxxx';
my $cmd="sh $script";
my $ssh = Net::SSH::Perl->new($host,port=>22);
$ssh->login($user,$passwd);
my ($stdout,$stderr,$exit) = $ssh->cmd("$cmd");
$ssh->cmd("exit");
if($exit != 0){
print "ErrorCode:$exit\n";
print "ErrorMsg:$stderr"; open( F, ">>", "/home/scan/mojo/log/$app-$ip-$XDATE.log" );
print F ("ErrorCode:$exit\n");
print F ("ErrorMsg:$stderr\n");
close F; $c->render(text => "ErrorCode:$exit;ErrorMsg:$stderr")
} else {
print $stdout;
open( F, ">>", "/home/scan/mojo/log/$app-$ip-$XDATE.log" );
print F ("ErrorCode:$exit\n");
print F ("ErrorMsg:$stderr\n");
print F ("$stdout\n");
close F;
$c->render(text => 'publish success')
} }; 脚本名字存放在数据库中: mysql> select * from publish_info;
+----+----------------+-----------------+------+---------------------------+
| sn | ip | info | env | script |
+----+----------------+-----------------+------+---------------------------+
| 1 | 121.xx.xx.9xx | uat-frontend | uat | /root/auto_run/publish.sh |
| 2 | 1.1.1.1 | aa | test | /root/auto_run/publish.sh |
| 3 | 121.xx.1xxx.1xx | zjzc-hy-pre-01 | uat | /root/auto_run/publish.sh |
| 6 | 121.0.1.8 | zjzc-hy-core-01 | uat | /root/auto_run/publish.sh |
+----+----------------+-----------------+------+---------------------------+
4 rows in set (0.00 sec) 调用的shell脚本内容:

Mojo 自动发布接口的更多相关文章

  1. SAP传输请求自动发布

        最近公司服务器做迁移,原R3 PRE需要迁到另外的地方,迁移后一段时间内,需要两套PRE环境同时运行,过一段时间后才将传输路线切换到新的PRE.在切换前,要求新PRE环境也要正常同步发布请求, ...

  2. WebApi使用swagger ui自动生成接口文档

    之前就写到.最近正在使用webapi.这里介绍一个实用的东西swageer ui现在开发都是前后端分开.我们这里是给前端提供api.有时候对于一个api的描述,并不想专门写一份文档.很浪费时间.swa ...

  3. GeoServer自动发布地图服务

    1 NetCDF气象文件自动发布案例 GeoServer是一个地理服务器,提供了管理页面进行服务发布,样式,切片,图层预览等一系列操作,但是手动进行页面配置有时并不满足业务需求,所以GeoServer ...

  4. drf07 过滤 排序 分页 异常处理 自动生成接口文档

    4. 过滤Filtering 对于列表数据可能需要根据字段进行过滤,我们可以通过添加django-fitlter扩展来增强支持. pip install django-filter 在配置文件sett ...

  5. Django实现自动发布(1数据模型)

    公司成立之初,业务量较小,一个程序包揽了所有的业务逻辑,此时服务器数量少,上线简单,基本开发-测试-上线都是由开发人员完成. 随着业务量逐渐上升,功能增多,代码量增大,而单一功能上线需要重新编译整个程 ...

  6. Jenkins持续集成(下)-Jenkins部署Asp.Net网站自动发布

    环境:Windows 2008 R2.Jenkins2.235.1.Visual Studio 2017: 概要 前面写过一篇文章,<自动发布-asp.net自动发布.IIS站点自动发布(集成S ...

  7. eclipse项目自动发布到tomcat目录,缺文件。

    eclipse项目自动发布到tomcat目录,缺文件. 解决方案: 项目--Properties-->Deployment Assembly-->Add--> Folder Add- ...

  8. php利用svn hooks将程序自动发布到测试环境

    利用svn hooks将php程序自动发布到测试环境 复制仓库hooks目录下的post-commit.tmpl为post-commit cp post-commit.tmpl post-commit ...

  9. 一键自动发布ipa(更新svn,拷贝资源,压缩资源,加密图片资源,加密数据文件,加密lua脚本,编译代码,ipa签名,上传ftp)

    一键自动发布ipa(更新svn,拷贝资源,压缩资源,加密图片资源,加密数据文件,加密lua脚本,编译代码,ipa签名,上传ftp) 程序员的生活要一切自动化,更要幸福^_^. 转载请注明出处http: ...

随机推荐

  1. css3: css3选择器

    --------------------css3选择器-------------------------css3属性选择器  ~~属性选择器基本上ie7+都支持,可以相对放心的使用 见: www.ca ...

  2. Spring Boot Memory Performance

    The Performance Zone is brought to you in partnership with New Relic. Quickly learn how to use Docke ...

  3. Linux批量重命名文件

    五种方法实现Linux批量重命名文件 Linux批量重命名文件是指对某些特定的文件统一进行重新命名,以改变原来一批文件的名称,这里介绍五种方法来实现. Linux批量重命名文件会涉及到改变一个字母.改 ...

  4. Microsoft SQL Server 混合云博客系列

    Microsoft 云操作系统愿景的核心支柱之一就是借助我们的混合云基础结构改造数据中心.在 Windows Azure 基础结构服务正式发布后的几个月里,我们一直在发布博客,介绍 Windows A ...

  5. T-SQL函数及用法--转

    转自http://www.cnblogs.com/qixuejia/archive/2010/07/14/1777105.html 1. 聚合函数 (1) AVG 函数功能返回组中值的平均值.空值将被 ...

  6. vue开发体验

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  7. 2.4.5 用NPOI操作EXCEL--插入图片

    我们知道,在Excel中是可以插入图片的.操作菜单是“插入->图片”,然后选择要插入图片,可以很容易地在Excel插入图片.同样,在NPOI中,利用代码也可以实现同样的效果.在NPOI中插入图片 ...

  8. 【转】Ubuntu 上编译Android出现cannot find -lstdc++解决办法

    [转]Ubuntu 上编译Android出现cannot find -lstdc++解决办法 在Ubuntu 12.04 x86_64机器上编译Android出现下面错误,是因为找不到32bit的li ...

  9. 通过SqlHelper实现登录

    1.建立解决方案:. 首先创建windows窗体应用程序,然后拖出登录界面 2. 写配置文件App.config:     <configuration>         <conn ...

  10. string.Format()字符串格式化

    Format()基本语法:     {索引[,对齐][:格式字符串]}     ·索引:表示引用的对象列表中的第n个对象参数.     ·对齐(可选):设置宽度与对齐方式,该参数为带符号的整数.正数为 ...