All Downloads are FREE. Search and download functionalities are using the official Maven repository.

shell.build-prod.gradle Maven / Gradle / Ivy

plugins {
  id 'org.hidetake.ssh' version '2.9.0'
}

repositories
{
	maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
	mavenCentral()
	jcenter()
}


ext {
	jarName='im-api-1.0.jar'
	serviceLocation='/data/program/im'
    serviceName='im api 服务'
}

dependencies 
{
		
}

ssh.settings {  
  knownHosts = allowAnyHosts
}

remotes
{
   no {  
    host = '10.100.102.23'
	user = 'root'
	port= 22
	password = '4m+mhSbxGY6veuFtRfufuBCW9VnImuUC102-23'
     //identity =  identity = file("${System.properties['user.home']}/.ssh/test/id_rsa")
  }
  no1 {  
    host = '10.100.102.24'
	user = 'root'
	port= 22
	password = 'WVsUWpNcZFVUGX+5iY11ex2ORfl3VJWP102-24'
     //identity =  identity = file("${System.properties['user.home']}/.ssh/test/id_rsa")
  } 
}


task deploy() << {  
  ssh.run {
		for(deployServer in remotes){
			String ip=deployServer.host 
			 session(deployServer){
			 
				  println "正在关闭 $ip 主机 $serviceName 服务..."
				 
				   //execute " $(cd `dirname $0`; pwd)"
	 			   execute "sh $serviceLocation/stop.sh",ignoreError:true
	 			  
	 			   println "删除 主机$ip 目录内容"
	 			   execute  "rm -fr $serviceLocation",ignoreError: true
	 			   
	 			   println "创建 主机$ip 目录"
	 			   execute "mkdir  -p $serviceLocation"
	 			   
				   println "上传 $jarName  到主机$ip  $serviceLocation"
	    		   put from: "./",into: "$serviceLocation"
			    
			       execute "rm -fr $serviceLocation/*.gradle"

                   execute "chmod +x $serviceLocation/start.sh"
                   execute "chmod +x $serviceLocation/stop.sh"

				   println "正在关闭 $ip 主机 $serviceName 服务..."
                   execute "sh $serviceLocation/start.sh"
                   
                   execute 'true'
                   println "$ip $serviceName 系统已经正常启动"
			}
    }  
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy