abc1181 commited on
Commit
d7efe47
·
verified ·
1 Parent(s): 93419f4

Update start_server.sh

Browse files
Files changed (1) hide show
  1. start_server.sh +19 -30
start_server.sh CHANGED
@@ -1,36 +1,25 @@
1
  #!/bin/bash
 
2
 
3
- NGX_NAME="${NGX_NAME:-admin}"
4
- NGX_PASS="${NGX_PASS:-admin}"
5
- CRYPTPASS=`openssl passwd -apr1 ${NGX_PASS}`
6
- PORT="${PORT:-8080}"
7
-
8
- echo "USERNAME:" $NGX_NAME
9
- echo "PASSWORD:" $NGX_PASS
10
-
11
- echo "${NGX_NAME}:${CRYPTPASS}" > ngpasswd
12
-
13
- COMMIT=$(cat /app/openvscode-server/product.json | awk '/commit/{print $4;exit}' FS='[""]')
14
- sed -i "s/#COMMIT#/$COMMIT/" nginx.conf
15
- sed -i "s/#PORT#/$PORT/" nginx.conf
16
- nginx -c $PWD/nginx.conf
17
 
18
- # Install huggingface_hub if not present
19
- pip install -q huggingface_hub 2>/dev/null
 
20
 
21
- # Start HF dataset sync in background
22
- echo "Starting HF dataset sync..."
23
- python3 scripts/sync_hf.py &
24
 
25
- git config --global user.name "$SPACE_AUTHOR_NAME"
26
- git config --global user.email "$SPACE_AUTHOR_NAME@hf.co"
27
- git config --global http.postBuffer 524288000
28
 
29
- echo "Starting VSCode Server..."
30
- vscode=/app/openvscode-server/bin/openvscode-server
31
- vscode_cli=/app/openvscode-server/bin/remote-cli/openvscode-server
32
- $vscode --install-extension ms-toolsai.jupyter
33
- $vscode --install-extension ms-python.python
34
- ln -s $vscode_cli $(dirname $vscode_cli)/code
35
- set -e
36
- exec $vscode --host 0.0.0.0 --port 5050 --without-connection-token "${@}" --
 
1
  #!/bin/bash
2
+ set -e
3
 
4
+ # 1. Move to the root workspace
5
+ cd /root/app
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ # 2. Start your dataset sync in the root context
8
+ # Ensure scripts/sync_hf.py uses /root/app/data
9
+ python3 scripts/sync_hf.py --path /root/app/data &
10
 
11
+ # 3. Setup Nginx (running as root)
12
+ nginx -c /root/app/nginx.conf
 
13
 
14
+ # 4. Launch VS Code forced into /root
15
+ # --user-data-dir and --extensions-dir are key to avoiding /home/user
16
+ vscode="/opt/openvscode-server/bin/openvscode-server"
17
 
18
+ exec $vscode \
19
+ --host 0.0.0.0 \
20
+ --port 5050 \
21
+ --without-connection-token \
22
+ --working-dir / \
23
+ --user-data-dir /root/.vscode-server \
24
+ --extensions-dir /root/.vscode-server/extensions \
25
+ "${@}"