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 [--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"
32 echo "Stopping any previous instances of Skyquake and API servers started with forever"
36 echo "Running Node.js Skyquake server. HTTPS Enabled: ${ENABLE_HTTPS}"
38 if [ ! -z "${ENABLE_HTTPS}" ]; then
39 forever start
-a -l forever.log
-o out.log
-e err.log skyquake.js
--enable-https --keyfile-path="${KEYFILE_PATH}" --certfile-path="${CERTFILE_PATH}"
41 forever start
-a -l forever.log
-o out.log
-e err.log skyquake.js
45 function extract_node_modules
() {
46 tar xf node_modules.
tar
50 function handle_plugin_node_modules
() {
52 echo "Handling plugin node modules"
56 echo "Checking plugin "${dir}" for newer node_modules"
58 if [ ! -f timestamp.txt
]; then
59 echo "timestamp file not found ... node_modules need to be expanded and timestamp needs to be touched"
62 echo "Checking if node_modules.tar has a newer timestamp than timestamp.txt"
63 if [[ node_modules.
tar -nt timestamp.txt
]]; then
64 echo "node_modules.tar is newer than timestamp ... node modules need to be expanded and timestamp needs to be touched"
67 echo "node_modules.tar is older than timestamp ... nothing needs to be done"
71 echo "Checking plugin "${dir}" for newer node_modules ...done"
80 -k=*|
--keyfile-path=*)
81 KEYFILE_PATH
="${i#*=}"
82 shift # past argument=value
84 -c=*|
--certfile-path=*)
85 CERTFILE_PATH
="${i#*=}"
86 shift # past argument=value
94 shift # past argument=value
102 if [[ ! -z "${ENABLE_HTTPS}" ]]; then
103 if [ -z "${KEYFILE_PATH}" ] ||
[ -z "${CERTFILE_PATH}" ]; then
110 # change to the directory of this script
111 THIS_DIR
=$
( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
113 # Call function to handle tarred node_modules as cpack+RPM cannot handle a lot of files
114 handle_plugin_node_modules
116 # Call function to start web and API servers
120 # Ensure that the forever script is stopped when this script exits
121 trap "echo \"Received EXIT\"; handle_received_signal" EXIT
122 trap "echo \"Received SIGINT\"; handle_received_signal" SIGINT
123 trap "echo \"Received SIGKILL\"; handle_received_signal" SIGKILL
124 trap "echo \"Received SIGABRT\"; handle_received_signal" SIGABRT
125 trap "echo \"Received SIGQUIT\"; handle_received_signal" SIGQUIT
126 trap "echo \"Received SIGSTOP\"; handle_received_signal" SIGSTOP
127 trap "echo \"Received SIGTERM\"; handle_received_signal" SIGTERM
128 trap "echo \"Received SIGTRAP\"; handle_received_signal" SIGTRAP
130 # Keep this script in the foreground so the system doesn't think that the