Commit 82bb3b87 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

added service shutdown code to stop service & remove apis

parent a694fc88
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -3,6 +3,13 @@ set -e

echo "MEEP_HOST_URL: ${MEEP_HOST_URL}"
echo "MEEP_SANDBOX_NAME: ${MEEP_SANDBOX_NAME}"
echo "MEEP_MEP_NAME: ${MEEP_MEP_NAME}"

if [[ ! -z "${MEEP_MEP_NAME}" ]]; then
    svcPath="${MEEP_SANDBOX_NAME}/${MEEP_MEP_NAME}"
else
    svcPath="${MEEP_SANDBOX_NAME}"
fi

# Update API yaml basepaths to enable "Try-it-out" feature
# OAS2: Set relative path to sandbox name + endpoint path (origin will be derived from browser URL)
@@ -10,14 +17,12 @@ echo "MEEP_SANDBOX_NAME: ${MEEP_SANDBOX_NAME}"
setBasepath() {
    # OAS3
    hostName=$(echo "${MEEP_HOST_URL}" | sed -E 's/^\s*.*:\/\///g')
    #newHostName=${hostName}/${MEEP_SANDBOX_NAME}
    echo "Replacing [localhost] with ${hostName} to url in: '$1'"
    sed -i "s,localhost,${hostName},g" "$1";

    # OAS2 and OAS3
    echo "Replacing [sandboxname] with ${MEEP_SANDBOX_NAME} to basepath or url in: '$1'"
    #sed -i 's,basePath: \"/\?,basePath: \"/'${MEEP_SANDBOX_NAME}'/,' $1;
    sed -i "s,sandboxname,${MEEP_SANDBOX_NAME},g" "$1";
    echo "Replacing [sandboxname] with ${svcPath} to basepath or url in: '$1'"
    sed -i "s,sandboxname,${svcPath},g" "$1";
}

# Set basepath for API files
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ func main() {
	count := 0
	for {
		if !run {
			server.Stop()
			log.Info("Ran for ", count, " seconds")
			break
		}
+11 −1
Original line number Diff line number Diff line
@@ -178,9 +178,19 @@ func Run() (err error) {

// Stop - Stop App Enablement
func Stop() {
	if mqLocal != nil {
		mqLocal.UnregisterHandler(handlerId)
	}

	// Remove APIs
	if apiMgr != nil {
		err := apiMgr.RemoveApis()
		if err != nil {
			log.Error("Failed to remove APIs with err: ", err.Error())
		}
	}
}

// Message Queue handler
func msgHandler(msg *mq.Msg, userData interface{}) {
	switch msg.Message {
+9 −4
Original line number Diff line number Diff line
@@ -3,6 +3,13 @@ set -e

echo "MEEP_HOST_URL: ${MEEP_HOST_URL}"
echo "MEEP_SANDBOX_NAME: ${MEEP_SANDBOX_NAME}"
echo "MEEP_MEP_NAME: ${MEEP_MEP_NAME}"

if [[ ! -z "${MEEP_MEP_NAME}" ]]; then
    svcPath="${MEEP_SANDBOX_NAME}/${MEEP_MEP_NAME}"
else
    svcPath="${MEEP_SANDBOX_NAME}"
fi

# Update API yaml basepaths to enable "Try-it-out" feature
# OAS2: Set relative path to sandbox name + endpoint path (origin will be derived from browser URL)
@@ -10,14 +17,12 @@ echo "MEEP_SANDBOX_NAME: ${MEEP_SANDBOX_NAME}"
setBasepath() {
    # OAS3
    hostName=$(echo "${MEEP_HOST_URL}" | sed -E 's/^\s*.*:\/\///g')
    #newHostName=${hostName}/${MEEP_SANDBOX_NAME}
    echo "Replacing [localhost] with ${hostName} to url in: '$1'"
    sed -i "s,localhost,${hostName},g" "$1";

    # OAS2 and OAS3
    echo "Replacing [sandboxname] with ${MEEP_SANDBOX_NAME} to basepath or url in: '$1'"
    #sed -i 's,basePath: \"/\?,basePath: \"/'${MEEP_SANDBOX_NAME}'/,' $1;
    sed -i "s,sandboxname,${MEEP_SANDBOX_NAME},g" "$1";
    echo "Replacing [sandboxname] with ${svcPath} to basepath or url in: '$1'"
    sed -i "s,sandboxname,${svcPath},g" "$1";
}

# Set basepath for API files
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ func main() {
	count := 0
	for {
		if !run {
			server.Stop()
			log.Info("Ran for ", count, " seconds")
			break
		}
Loading