dever 7 years ago
parent
commit
e52bbf1fff

+ 11 - 0
src/docker/build/os/alpine/v3.4/entrypoint.sh

@@ -16,6 +16,17 @@ hosts()
         fi
     fi
 }
+get_ip()
+{
+    check=`ifconfig|grep eth1`
+    if [ "$check" != "" ]; then
+        ip=`ifconfig eth1|grep "inet addr:"|awk -F":" '{print $2}'|awk '{print $1}'`
+    else
+        ip=`ifconfig eth0|grep "inet addr:"|awk -F":" '{print $2}'|awk '{print $1}'`
+    fi
+
+    echo $ip
+}
 process()
 {
     echo "$1 Startup Completed" > /share/process/$1

+ 2 - 2
src/docker/build/service/consul/consul.sh

@@ -1,9 +1,9 @@
-#!/bin/bash
+#!/usr/bin/env sh
 set -e
 
 start_consul()
 {
-	ip=`ifconfig eth0|grep "inet addr:"|awk -F":" '{print $2}'|awk '{print $1}'`
+	ip=`get_ip`
 	if [ "$1" == "server" ]; then
 		process_start consul agent -server -bootstrap-expect 1 -data-dir /root/consul/data -config-dir /root/consul/config -client 0.0.0.0
 	elif [ "$1" == "client" ]; then

+ 1 - 0
src/docker/conf/daemon.conf

@@ -5,6 +5,7 @@ network = overlay_dm
 
 [master]
 image = consul
+port = 8500
 volumes = {container}conf/service/consul:/root/consul/config
 command = consul -server -bootstrap-expect 3 -data-dir=/root/consul/data -config-dir=/root/consul/config -client=0.0.0.0 -node={name} -dc={name}
 alias = consul

+ 5 - 7
src/tool/cluster.py

@@ -223,8 +223,8 @@ class Cluster_Action(Docker_Action):
 		token = Swarm.init(ip)
 		
 		if token and '--token' in token:
-			command = 'ds run daemon-master'
-			Core.popen(command, True, bg=False)
+			Core.popen('dm pull consul')
+			Core.popen('ds run daemon-master')
 
 			token = token.split('docker swarm join --token ')
 			token = token[1].split("\r\n")
@@ -232,8 +232,7 @@ class Cluster_Action(Docker_Action):
 			data = token.split(':')
 			ip = data[1]
 
-			command = 'consul kv put ' + ckey + ' ' + token
-			Core.popen(command, True, bg=True)
+			Core.popen('consul kv put ' + ckey + ' ' + token)
 		print 'init cluster('+ip+'):yes'
 
 	@classmethod
@@ -252,11 +251,10 @@ class Cluster_Action(Docker_Action):
 			print config
 
 			'''
-
+			Core.popen('dm pull consul')
 			Swarm.join(config[0])
 
-			command = 'dm run daemon-client'
-			Core.popen(command, True, bg=False)
+			Core.popen('dm run daemon-client')
 
 			print 'join cluster:yes'
 			'''