-
Notifications
You must be signed in to change notification settings - Fork 5
/
startup.sh
55 lines (43 loc) · 1.48 KB
/
startup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
tenant=$1
# Read values from config.toml
user=$(sed -n 's/^user = "\([^"]*\)"/\1/p' artifacts/config.toml)
password=$(sed -n 's/^password = "\([^"]*\)"/\1/p' artifacts/config.toml)
database=$(sed -n 's/^database = "\([^"]*\)"/\1/p' artifacts/config.toml)
host=$(sed -n 's/^host = "\([^"]*\)"/\1/p' artifacts/config.toml)
port=$(sed -n 's/^port = "\([^"]*\)"/\1/p' artifacts/config.toml)
# Export password to avoid psql prompt
export PGPASSWORD=$password
# Unset the password variable for security
unset PGPASSWORD
cleanup() {
echo "Stopping the processes..."
# Kill the Java process
if [ -n "$java_pid" ]; then
kill "$java_pid" 2>/dev/null
fi
# Kill the Node.js process
if [ -n "$node_pid" ]; then
kill "$node_pid" 2>/dev/null
fi
# Wait for both processes to terminate
wait "$java_pid" 2>/dev/null
wait "$node_pid" 2>/dev/null
echo "All processes have been stopped."
exit 1
}
# Trap Ctrl+C (SIGINT) and call the cleanup function
trap cleanup SIGINT SIGTERM EXIT
cd artifacts
# Start the Java application
echo "Starting Backend service..."
java -jar devportal.jar &
java_pid=$! # Capture the process ID of the Java process
# Start the Node.js application
echo "Starting Devportal application..."
if [ "$tenant" == "single" ] || [ "$tenant" == "dev" ]; then
npm run build-css --watch & node ../node_modules/devportal-webapp/src/single-tenant.js
else
node ../node_modules/devportal-webapp/src/multi-tenant.js
fi
node_pid=$!