forked from conductor-oss/conductor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconductor_server.sh
More file actions
executable file
·80 lines (69 loc) · 2.42 KB
/
conductor_server.sh
File metadata and controls
executable file
·80 lines (69 loc) · 2.42 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
# Conductor Server Startup Script
# Downloads the server JAR if missing and starts it with java
#
# Usage:
# Interactive: ./conductor_server.sh
# With args: ./conductor_server.sh [PORT] [VERSION]
# ./conductor_server.sh 9090 3.22.0
# ./conductor_server.sh 9090
# ./conductor_server.sh latest (uses default port 8080)
# One-liner: curl -sSL https://raw.githubusercontent.com/conductor-oss/conductor/main/conductor_server.sh | sh
# With args: curl ... | sh -s -- 9090 3.22.0
# Check for Java and version 21+
if ! command -v java >/dev/null 2>&1; then
echo "Error: Java is not installed or not in PATH"
exit 1
fi
JAVA_VERSION=$(java -version 2>&1 | head -n 1 | sed -E 's/.*"([0-9]+).*/\1/')
if [ -z "$JAVA_VERSION" ] || [ "$JAVA_VERSION" -lt 21 ] 2>/dev/null; then
echo "Error: JDK 21 or higher is required. Current version: $(java -version 2>&1 | head -n 1)"
exit 1
fi
# Defaults
SERVER_PORT=8080
CONDUCTOR_VERSION="latest"
REPO_URL="https://conductor-server.s3.us-east-2.amazonaws.com"
# Argument parsing: check if args are port numbers or versions
for arg in "$@"; do
if echo "$arg" | grep -q "^[0-9][0-9]*$"; then
SERVER_PORT="$arg"
else
CONDUCTOR_VERSION="$arg"
fi
done
# If running interactively and no args provided, prompt user
if [ $# -eq 0 ] && [ -z "$CONDUCTOR_PORT" ] && [ -t 0 ]; then
printf "Enter the port for Server [8080]: "
read input_port </dev/tty
if [ -n "$input_port" ]; then
SERVER_PORT="$input_port"
fi
printf "Enter the version [latest]: "
read input_version </dev/tty
if [ -n "$input_version" ]; then
CONDUCTOR_VERSION="$input_version"
fi
elif [ -n "$CONDUCTOR_PORT" ] && [ $# -eq 0 ]; then
SERVER_PORT="$CONDUCTOR_PORT"
fi
JAR_NAME="conductor-server-${CONDUCTOR_VERSION}.jar"
JAR_URL="${REPO_URL}/${JAR_NAME}"
# Use CONDUCTOR_HOME if set, otherwise use current directory
if [ -z "$CONDUCTOR_HOME" ]; then
CONDUCTOR_HOME="."
fi
JAR_PATH="$CONDUCTOR_HOME/$JAR_NAME"
# Download JAR if not present
if [ ! -f "$JAR_PATH" ]; then
echo "Downloading Conductor Server ${CONDUCTOR_VERSION}..."
mkdir -p "$CONDUCTOR_HOME"
curl -L -o "$JAR_PATH" "$JAR_URL"
if [ $? -ne 0 ]; then
echo "Failed to download Conductor Server JAR from $JAR_URL"
exit 1
fi
echo "Downloaded to $JAR_PATH"
fi
echo "Starting Conductor Server ${CONDUCTOR_VERSION} on port $SERVER_PORT..."
java -jar "$JAR_PATH" --server.port=$SERVER_PORT