4 # Copyright 2016 RIFT.IO Inc
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
20 echo "usage: launch_ui.sh --launchpad-address=<ip_or_fqdn> --idp-port-number=<port_number> [--enable-https --keyfile-path=<keyfile_path> --certfile-path=<certfile-path>]"
23 function handle_received_signal
() {
25 echo "Stopped Skyquake and API servers started with forever"
29 # Gets the current hosts ip/fqdn. If the host is resolvable through dns, it
30 # returns the fqdn else returns the ip address.
32 if [[ -z $
(hostname
-d) ]]; then
33 # not resolvable via dns, use resolvable ip address
34 echo $
(hostname
--ip-address)
37 echo $
(hostname
--fqdn)
43 echo "Stopping any previous instances of Skyquake and API servers started with forever"
46 local launchpad_address
=$
(get_host_address
)
48 echo "Running Node.js Skyquake server. HTTPS Enabled: ${ENABLE_HTTPS}, Launchpad Address: ${launchpad_address}"
50 if [ ! -z "${ENABLE_HTTPS}" ]; then
51 forever start
-a -l forever.log
-o out.log
-e err.log skyquake.js
--enable-https --keyfile-path="${KEYFILE_PATH}" --certfile-path="${CERTFILE_PATH}" --launchpad-address="${LAUNCHPAD_ADDRESS}" --idp-port-number="${IDP_PORT_NUMBER}" --callback-address="${CALLBACK_ADDRESS}"
53 forever start
-a -l forever.log
-o out.log
-e err.log skyquake.js
--launchpad-address="${LAUNCHPAD_ADDRESS}" --idp-port-number="${IDP_PORT_NUMBER}" --callback-address="${CALLBACK_ADDRESS}"
61 -k=*|
--keyfile-path=*)
62 KEYFILE_PATH
="${i#*=}"
63 shift # past argument=value
65 -c=*|
--certfile-path=*)
66 CERTFILE_PATH
="${i#*=}"
67 shift # past argument=value
69 -l=*|
--launchpad-address=*)
70 LAUNCHPAD_ADDRESS
="${i#*=}"
71 shift # past argument=value
73 -p=*|
--idp-port-number=*)
74 IDP_PORT_NUMBER
="${i#*=}"
75 shift # past argument=value
77 -r=*|
--callback-address=*)
78 CALLBACK_ADDRESS
="${i#*=}"
79 shift # past argument=value
87 shift # past argument=value
95 if [[ ! -z "${ENABLE_HTTPS}" ]]; then
96 if [ -z "${KEYFILE_PATH}" ] ||
[ -z "${CERTFILE_PATH}" ]; then
103 # change to the directory of this script
104 THIS_DIR
=$
( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
108 # Call script to handle tarred node_modules as cpack+RPM cannot handle a lot of files
109 $THIS_DIR/handle_plugin_node_modules
111 # Call function to start web and API servers
115 # Ensure that the forever script is stopped when this script exits
116 trap "echo \"Received EXIT\"; handle_received_signal" EXIT
117 trap "echo \"Received SIGINT\"; handle_received_signal" SIGINT
118 trap "echo \"Received SIGKILL\"; handle_received_signal" SIGKILL
119 trap "echo \"Received SIGABRT\"; handle_received_signal" SIGABRT
120 trap "echo \"Received SIGQUIT\"; handle_received_signal" SIGQUIT
121 trap "echo \"Received SIGSTOP\"; handle_received_signal" SIGSTOP
122 trap "echo \"Received SIGTERM\"; handle_received_signal" SIGTERM
123 trap "echo \"Received SIGTRAP\"; handle_received_signal" SIGTRAP
125 # Keep this script in the foreground so the system doesn't think that the