Skip to content

Instantly share code, notes, and snippets.

@tmkasun
Last active October 17, 2019 09:02
Show Gist options
  • Select an option

  • Save tmkasun/2217956f1872d29bc50a0ed322e2b7fe to your computer and use it in GitHub Desktop.

Select an option

Save tmkasun/2217956f1872d29bc50a0ed322e2b7fe to your computer and use it in GitHub Desktop.
Setup APIM server and Run it with it's depending servers, Will only be useful until API manager product properly pack the dependencies in to final product. Till we get there ...
#! /usr/bin/env bash
# HOW TO USE: Put this file inside the directory where you would like to extract and run the product-APIM build file (.zip file)
# Change the below path variables accordingly *** NOTE: No ending `/` slashes has been used
source_path="/home/tmkasun/Documents/wso2/dev/products/team/apim/carbon-apimgt-forked/features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher"
product_apimgt_path="/home/tmkasun/Documents/wso2/dev/products/team/apim/product-apim-forked"
pack_name="wso2apim-3.0.0-SNAPSHOT"
active_mq_dir="/home/tmkasun/Documents/wso2/dev/tools/apache-activemq-5.14.0"
is_pack_path="/home/tmkasun/Documents/wso2/dev/products/is/latest/release/wso2is-5.3.0"
action=$1
create_symlink() {
sources=$1
destination=$2
mv $destination "${destination}_back"
ln -s "${sources}" "${destination}"
}
run() {
echo "Running the setup ..."
echo "Starting activeMQ ..."
activemq start
echo "Starting IS ..."
# For mac use open -a Terminal "`pwd`"
gnome-terminal --tab -e "${is_pack_path}/bin/wso2server.sh"
echo "Starting ballerina APIM Gateway Server ..."
ballerina_build_path="${product_apimgt_path}/gateway/target"
# Intentionally delayed to sync with APIM server startup
(sleep 20 && cd "${ballerina_build_path}/wso2apim-gateway-3.0.0-SNAPSHOT/" && sed -i -e 's/\r$//' ./bin/ballerina && gnome-terminal --tab -e "./bin/ballerina run service org/wso2/carbon/apimgt/gateway") &
echo "Starting APIM ..."
./${pack_name}/bin/carbon.sh
}
setup() {
echo "Setting-up the environment ..."
echo "coping ${pack_name}zip from product apimgt build path to here ..."
cp "${product_apimgt_path}/product/target/${pack_name}.zip" .
echo "Removing exsisting $pack_name"
rm -R ${pack_name}
echo "Unziping $pack_name"
code=$(unzip "${pack_name}.zip")
if ! type activemq > /dev/null; then
echo "Can't find active MQ installed, running from directory ..."
export PATH="${active_mq_dir}/bin/:$PATH"
fi
echo "Unzipping gateway server ..."
ballerina_build_path="${product_apimgt_path}/gateway/target"
rm -R "${ballerina_build_path}/wso2apim-gateway-3.0.0-SNAPSHOT"
(cd ${ballerina_build_path} && unzip "wso2apim-gateway-3.0.0-SNAPSHOT.zip")
echo "Creating symlinks for Publisher ..."
create_symlink "${source_path}/public" "${pack_name}/deployment/webapps/publisher/public"
run
}
if [ "$action" == "setup" ]; then
setup
elif [ "$action" == "run" ]; then
run
else
echo "Unknown parameter. Type either 'setup' or 'run'"
fi
exit 1
@bhathiya
Copy link
Copy Markdown

bhathiya commented Jul 19, 2017

at the end of line 37, it should be "./bin/ballerina run service services.bsz"

@tmkasun
Copy link
Copy Markdown
Author

tmkasun commented Aug 4, 2017

Thank you @bhathiya ๐Ÿ˜Š
I have added that change to the gist ๐Ÿ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment