export GOPATH="C:/Go"

EXTERNAL="127.0.0.1"
LEVEL="debug"
ETCD="http://127.0.0.1:18153"
REDIS_HOST="127.0.0.1"
REDIS_PORT="18151"
MYSQL_HOST="127.0.0.1"
MYSQL_PORT="18152"
MYSQL_DATABASE_NAME="iot-hub"
MYSQL_USERNAME="root"
MYSQL_PASSWORD="Luzhenqian@0807"
RABBIT_URI="amqp://guest:guest@127.0.0.1:18154"

taskkill -im httpaccess.exe \
-im registry.exe \
-im apiprovider.exe \
-im devicemanager.exe \
-im controller.exe \
-im mqttaccess.exe \
-im knowoapi.exe \
-im fileaccess.exe \
-im coapaccess.exe -f

$GOPATH/bin/httpaccess.exe -etcd $ETCD -httphost external:18100 -external $EXTERNAL -redishost $REDIS_HOST:$REDIS_PORT -loglevel $LEVEL > httpaccess.out 2>&1 &
$GOPATH/bin/registry.exe -etcd $ETCD -rpchost internal:18101 -aeskey ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP -dbhost $MYSQL_HOST -dbname $MYSQL_DATABASE_NAME -dbport $MYSQL_PORT -dbuser $MYSQL_USERNAME -dbpass $MYSQL_PASSWORD -loglevel $LEVEL > registry.out  2>&1 &
$GOPATH/bin/apiprovider.exe -etcd $ETCD -loglevel $LEVEL -httphost external:18102 -external $EXTERNAL > apiprovider.out 2>&1 &
$GOPATH/bin/devicemanager.exe -etcd $ETCD -loglevel $LEVEL -rpchost internal:18103 -redishost $REDIS_HOST:$REDIS_PORT >devicemanager.out 2>&1 &
$GOPATH/bin/controller.exe -etcd $ETCD -rabbithost $RABBIT_URI -loglevel $LEVEL -rpchost internal:18104 > controller.out 2>&1 &
$GOPATH/bin/mqttaccess.exe -etcd $ETCD -loglevel $LEVEL -rpchost internal:18105 -tcphost external:18106 -external $EXTERNAL > mqttaccess.out 2>&1 &
$GOPATH/bin/knowoapi.exe -etcd $ETCD -loglevel $LEVEL  -httphost external:18107 -dbhost $MYSQL_HOST -dbname $MYSQL_DATABASE_NAME -dbport $MYSQL_PORT -dbuser $MYSQL_USERNAME -dbpass $MYSQL_PASSWORD -aeskey ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP -external $EXTERNAL> konowapi.out 2>&1 &
$GOPATH/bin/fileaccess.exe -etcd $ETCD -loglevel $LEVEL  -rpchost internal:18108 -httphost internal:18109 > fileaccess.out 2>&1 &
$GOPATH/bin/coapaccess.exe -etcd $ETCD -loglevel $LEVEL  -udphost internal:18110 >caopaccess.out 2>&1 &
exit 0