PYAE1994 commited on
Commit
33e6e72
·
verified ·
1 Parent(s): 4aa8f9e

Update start_server.sh

Browse files
Files changed (1) hide show
  1. start_server.sh +38 -16
start_server.sh CHANGED
@@ -4,55 +4,77 @@ set -e
4
 
5
  echo "🚀 Starting VSCode AI Space..."
6
 
 
 
 
 
 
 
 
 
 
7
  # ========================
8
  # Auth
9
  # ========================
10
  NGX_NAME="${NGX_NAME:-admin}"
11
  NGX_PASS="${NGX_PASS:-admin}"
12
- CRYPTPASS=$(openssl passwd -apr1 ${NGX_PASS})
13
 
14
- echo "${NGX_NAME}:${CRYPTPASS}" > ngpasswd
 
 
15
 
16
  # ========================
17
  # nginx config
18
  # ========================
19
  COMMIT=$(cat /app/openvscode-server/product.json | awk '/commit/{print $4;exit}' FS='[""]')
20
 
21
- sed -i "s/#COMMIT#/$COMMIT/" nginx.conf
22
- sed -i "s/#PORT#/${PORT:-8080}/" nginx.conf
23
 
24
- nginx -c $PWD/nginx.conf
 
 
25
 
26
  # ========================
27
- # Repo clone
28
  # ========================
29
  if [[ ! -z "$REPO" ]]; then
30
  dir=$(basename "$REPO" .git)
31
- git clone $REPO $dir
 
 
 
 
32
  fi
33
 
34
  git config --global http.postBuffer 524288000
35
 
36
  # ========================
37
- # Agent
38
  # ========================
39
- # STEP 2 ADD
40
- if [ -f "/app/agent/agent.py" ]; then
41
  echo "🧠 Starting AI Agent..."
42
- python3 /app/agent/agent.py &
 
 
 
 
 
43
  fi
44
 
45
  # ========================
46
  # VSCode Server
47
  # ========================
48
- vscode=/app/openvscode-server/bin/openvscode-server
 
 
49
 
50
- $vscode --install-extension ms-toolsai.jupyter
51
- $vscode --install-extension ms-python.python
52
 
53
- echo "✅ Starting VSCode..."
54
 
55
- exec $vscode \
56
  --host 0.0.0.0 \
57
  --port 5050 \
58
  --without-connection-token
 
4
 
5
  echo "🚀 Starting VSCode AI Space..."
6
 
7
+ # ========================
8
+ # Prepare nginx runtime dirs
9
+ # ========================
10
+ mkdir -p /tmp/nginx/body
11
+ mkdir -p /tmp/nginx/proxy
12
+ mkdir -p /tmp/nginx/fastcgi
13
+ mkdir -p /tmp/nginx/uwsgi
14
+ mkdir -p /tmp/nginx/scgi
15
+
16
  # ========================
17
  # Auth
18
  # ========================
19
  NGX_NAME="${NGX_NAME:-admin}"
20
  NGX_PASS="${NGX_PASS:-admin}"
 
21
 
22
+ CRYPTPASS=$(openssl passwd -apr1 "${NGX_PASS}")
23
+
24
+ echo "${NGX_NAME}:${CRYPTPASS}" > /home/user/app/ngpasswd
25
 
26
  # ========================
27
  # nginx config
28
  # ========================
29
  COMMIT=$(cat /app/openvscode-server/product.json | awk '/commit/{print $4;exit}' FS='[""]')
30
 
31
+ sed -i "s/#COMMIT#/$COMMIT/" /home/user/app/nginx.conf
32
+ sed -i "s/#PORT#/${PORT:-8080}/" /home/user/app/nginx.conf
33
 
34
+ echo "🌐 Starting nginx..."
35
+
36
+ nginx -c /home/user/app/nginx.conf
37
 
38
  # ========================
39
+ # Optional repo clone
40
  # ========================
41
  if [[ ! -z "$REPO" ]]; then
42
  dir=$(basename "$REPO" .git)
43
+
44
+ if [ ! -d "$dir" ]; then
45
+ echo "📦 Cloning repo..."
46
+ git clone "$REPO" "$dir"
47
+ fi
48
  fi
49
 
50
  git config --global http.postBuffer 524288000
51
 
52
  # ========================
53
+ # AI Agent
54
  # ========================
55
+ if [ -f "/home/user/app/app/agent/agent.py" ]; then
 
56
  echo "🧠 Starting AI Agent..."
57
+ python3 /home/user/app/app/agent/agent.py &
58
+ elif [ -f "/home/user/app/agent/agent.py" ]; then
59
+ echo "🧠 Starting AI Agent..."
60
+ python3 /home/user/app/agent/agent.py &
61
+ else
62
+ echo "⚠️ agent.py not found"
63
  fi
64
 
65
  # ========================
66
  # VSCode Server
67
  # ========================
68
+ VSCODE=/app/openvscode-server/bin/openvscode-server
69
+
70
+ echo "🔌 Installing VSCode extensions..."
71
 
72
+ $VSCODE --install-extension ms-toolsai.jupyter || true
73
+ $VSCODE --install-extension ms-python.python || true
74
 
75
+ echo "✅ Starting OpenVSCode Server..."
76
 
77
+ exec $VSCODE \
78
  --host 0.0.0.0 \
79
  --port 5050 \
80
  --without-connection-token