-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
235 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
bin/ | ||
target/ | ||
file/ | ||
logs/ | ||
gen-java/ | ||
.externalToolBuilders/ | ||
.settings/ | ||
.gradle/ | ||
.classpath | ||
.gradletasknamecache | ||
.buildpath | ||
.project | ||
.springBeans | ||
dependency-reduced-pom.xml | ||
*.iml | ||
nohup.out | ||
/tmp | ||
/.apt_generated/ | ||
.idea/ | ||
disconf/ | ||
/target/ | ||
/build/ | ||
/out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# 项目介绍 | ||
rancher容器部署的agent,提供宿主机的host给对接app的容器使用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apply plugin: 'application' | ||
|
||
dependencies { | ||
compile project(':skyeye-base') | ||
} | ||
|
||
configurations { | ||
compile.exclude group: "log4j", module: "log4j" | ||
compile.exclude group: "org.slf4j", module: "slf4j-log4j12" | ||
compile.exclude group: "org.springframework", module: "spring-web" | ||
} | ||
|
||
mainClassName = 'com.jthink.skyeye.agent.launcher.Launcher' | ||
|
||
buildscript { | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { url mavenPublicUrl } | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("io.spring.gradle:dependency-management-plugin:$gradlePluginVersion") | ||
} | ||
} | ||
|
||
startScripts { | ||
doLast { | ||
unixScript.text = unixScript.text.replaceAll("lib/(.*)\n", "lib/\\*") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# build the base image: jdk | ||
# this is the docker file, use the jdk 8u144-ubuntu16.04 | ||
# VERSION 1 | ||
# Author: leviqian | ||
|
||
# the basic image | ||
FROM 192.168.88.73:8888/common/jdk:8u144-ubuntu16.04 | ||
|
||
# maintainer | ||
MAINTAINER leviqian [email protected] | ||
|
||
# get the args | ||
ARG version | ||
|
||
# set env | ||
ENV VERSION $version | ||
|
||
# copy the file | ||
RUN mkdir -p /home/deploy | ||
ADD skyeye-agent-$version.tar /home/deploy | ||
COPY run.sh /run.sh | ||
RUN chmod +x /run.sh | ||
|
||
# CMD to start | ||
CMD ["/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
version=$1 | ||
cp ../target/distributions/*.tar . | ||
|
||
sudo docker build --build-arg version=$version -t 192.168.88.73:8888/skyeye/skyeye-agent:$version . | ||
sudo docker push 192.168.88.73:8888/skyeye/skyeye-agent:$version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
source /etc/profile.d/java.sh | ||
|
||
cd /home/deploy/skyeye-agent-$VERSION | ||
nohup bin/skyeye-agent & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'skyeye-agent' |
20 changes: 20 additions & 0 deletions
20
skyeye-agent/src/main/java/com/jthink/skyeye/agent/launcher/Launcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.jthink.skyeye.agent.launcher; | ||
|
||
import com.jthink.skyeye.base.util.DockerHostUtil; | ||
|
||
/** | ||
* JThink@JThink | ||
* | ||
* @author JThink | ||
* @version 0.0.1 | ||
* @desc 项目启动器 | ||
* @date 2016-08-24 18:31:48 | ||
*/ | ||
public class Launcher { | ||
|
||
public static void main(String[] args) { | ||
// 进行宿主机host获取, 并写入 | ||
String host = DockerHostUtil.getHostFromLocal(); | ||
DockerHostUtil.writeToFile(host); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ artifacts { | |
//} | ||
|
||
dependencies { | ||
|
||
compile "org.slf4j:slf4j-api:$slf4jVersion" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
skyeye-base/src/main/java/com/jthink/skyeye/base/util/DockerHostUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.jthink.skyeye.base.util; | ||
|
||
import com.jthink.skyeye.base.constant.Constants; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.*; | ||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
/** | ||
* JThink@JThink | ||
* | ||
* @author JThink | ||
* @version 0.0.1 | ||
* @desc docker部署app情况下获取host的工具包 | ||
* @date 2017-12-07 19:38:39 | ||
*/ | ||
public class DockerHostUtil { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(DockerHostUtil.class); | ||
|
||
/** | ||
* 从运行机器获取host | ||
* @return | ||
*/ | ||
public static String getHostFromLocal() { | ||
try { | ||
return (InetAddress.getLocalHost()).getHostName(); | ||
} catch (UnknownHostException uhe) { | ||
String host = uhe.getMessage(); | ||
if (host != null) { | ||
int colon = host.indexOf(Constants.COLON); | ||
if (colon > 0) { | ||
return host.substring(0, colon); | ||
} | ||
} | ||
|
||
} | ||
return Constants.UNKNOWN_HOST; | ||
} | ||
|
||
/** | ||
* 将host写入到 | ||
* @param host | ||
* @return | ||
*/ | ||
public static void writeToFile(String host) { | ||
BufferedWriter bw = null; | ||
try { | ||
File file = new File(Constants.SKYEYE_HOST_FILE); | ||
if (!file.getParentFile().exists()) { | ||
if (!file.getParentFile().mkdirs()) { | ||
LOGGER.info("创建父文件夹失败"); | ||
} | ||
} | ||
bw = new BufferedWriter(new FileWriter(file, false)); | ||
bw.write(host); | ||
} catch (IOException e) { | ||
LOGGER.info("写文件报错, ", e); | ||
} finally { | ||
if (bw != null) { | ||
try { | ||
bw.flush(); | ||
bw.close(); | ||
} catch (IOException e) { | ||
LOGGER.info("写文件报错, ", e); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* 从文件中读取host | ||
* @return | ||
*/ | ||
public static String readFromFile() { | ||
BufferedReader br = null; | ||
try { | ||
br = new BufferedReader(new FileReader(Constants.SKYEYE_HOST_FILE)); | ||
return br.readLine(); | ||
} catch (IOException e) { | ||
LOGGER.error("读文件报错, ", e); | ||
} catch (Exception e) { | ||
LOGGER.error("解密出错, ", e); | ||
} finally { | ||
if (br != null) { | ||
try { | ||
br.close(); | ||
} catch (IOException e) { | ||
LOGGER.info("读文件报错, ", e); | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters