# Steps to setup a SMILE server

# Set up Java:

  1. install java
  2. create JAVA_HOME environment variable & add java bin to class path

# Set up mongo:

  1. create installs folder

  2. download mongodb:

    wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz

  3. untar the downloaded zip into installs folder

  4. create folder db/mongo/data

  5. add the following files under mongo bin:

    1. mongodbconfig
    dbpath = /home/ubuntu/db/mongo/data
    logpath = /home/ubuntu/db/mongo/mongodb.log
    logappend = true
    port = 27017
    #replSet = abc
    bind_ip = 0.0.0.0
    
    1. mongostart
    sudo ~/installs/mongodb-linux-x86_64-ubuntu1804-4.2.8/bin/mongod --config ~/installs/mongodb-linux-x86_64-ubuntu1804-4.2.8/bin/mongodbconfig
    
    1. mongostop
    #!/bin/bash
    pid=`ps -aef | grep mongod | grep mongodbconfig -m 1 | tr -s " " | cut -f2 -d " "`;
    if [ "${pid}" != "" ]; then
    sudo kill -2 ${pid};
    fi
    
  6. provide the start & stop files execute access

  7. start mongo server

  8. Optionally add mongo bin to class path & start mongo server on machine start-up.

    export MONGO_HOME="/home/ubuntu/installs/mongodb-linux-x86_64-ubuntu1804-4.2.8"
    export PATH=~/bin:$JAVA_HOME/bin:$MONGO_HOME/bin:$PATH
    

# Set up release folder:

  1. create a folder named release

  2. under release create the following folders

    1. shipped
    2. backup
  3. add the following scripts:

    1. deploy.sh

      ZIP_FILE="homer-release-0.1_stage.zip"
      RELEASE_FOLDER="homer-release-0.1"
      LOCAL_FOLDER="homer-release"
      echo "moving old zip to backup/"
      rm -f backup/$ZIP_FILE
      cp -rf $ZIP_FILE backup/
      echo "deleting old releases"
      sudo rm -rf $ZIP_FILE
      sudo rm -rf $LOCAL_FOLDER
      echo "copying release zip here"
      cp -r shipped/$ZIP_FILE .
      unzip $ZIP_FILE
      echo "renaming release zip"
      mv $RELEASE_FOLDER $LOCAL_FOLDER
      chmod +x $LOCAL_FOLDER/bin/*
      chmod +x $LOCAL_FOLDER/*
      echo "copy data folder"
      rm -rf data
      cp -r shipped/data .
      
    2. start-server.sh

      nohup ./homer-release/bin/homer -Dsmile.env=dev -Dhttp.port=9000 -Dpidfile.path=/home/ubuntu/ebs/release/play.pid &
      
    3. stop-server.sh

      kill `cat ./play.pid`
      
  4. copy the executable to shipped folder

  5. run deploy.sh

  6. run start-server.sh

  7. verify if server is running on 9000 port.