Skip to content

Instantly share code, notes, and snippets.

@hophacker
Last active April 11, 2016 17:16
Show Gist options
  • Save hophacker/d3642d067d56e5edbc9bd6792a77c96a to your computer and use it in GitHub Desktop.
Save hophacker/d3642d067d56e5edbc9bd6792a77c96a to your computer and use it in GitHub Desktop.

Revisions

  1. Jie Feng renamed this gist Apr 11, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Jie Feng created this gist Apr 11, 2016.
    37 changes: 37 additions & 0 deletions start.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #!/bin/bash -

    set -o nounset # Treat unset variables as an error

    port=3002
    search=false
    RAILS_ENV=${RAILS_ENV:-development}

    while getopts p:e:rw:s opt
    do
    case "$opt" in
    p)
    port=$OPTARG
    ;;
    s)
    search=true
    ;;
    [?]) echo -e >&2 "Usage: \n\t-e [environment: default development | production] \n\t-p [port: default 80]"
    exit 1
    ;;
    esac
    done

    if [ $search = true ]; then
    bundle exec rake sunspot:solr:start
    bundle exec rake sunspot:solr:reindex
    fi

    export ROOT_URL=${ROOT_URL:-http://trainwith.cn/}
    if [ $RAILS_ENV = "development" ]; then
    export BAIDU_MAP_API_KEY="v9cvM6PLGPhfoeQA35b5dsVu"
    elif [ $RAILS_ENV = "production" ]; then
    export BAIDU_MAP_API_KEY="eD9GHzQcS2Zl1QPtGRDikPW5"
    fi
    export QINIU_DOMAIN="http://7xpmg1.com1.z0.glb.clouddn.com"
    export SECRET_KEY_BASE=$(openssl rand -hex 64)
    rails s -b 0.0.0.0 -p $port