atonyxu
commited on
Commit
·
1c11206
1
Parent(s):
993dc67
code
Browse files- __pycache__/main.cpython-311.pyc +0 -0
- main.py +19 -2
- start_server.sh +3 -7
__pycache__/main.cpython-311.pyc
ADDED
Binary file (1.35 kB). View file
|
|
main.py
CHANGED
@@ -1,7 +1,24 @@
|
|
1 |
from fastapi import FastAPI
|
|
|
|
|
|
|
|
|
2 |
|
3 |
app = FastAPI()
|
4 |
|
5 |
@app.get("/")
|
6 |
-
def read_root():
|
7 |
-
return {"message": "Hello, World!"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
import subprocess
|
3 |
+
import time
|
4 |
+
import os
|
5 |
+
import signal
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
9 |
@app.get("/")
|
10 |
+
async def read_root():
|
11 |
+
return {"message": "Hello, World!"}
|
12 |
+
|
13 |
+
if __name__ == "__main__":
|
14 |
+
# Start the server in a separate process
|
15 |
+
server_process = subprocess.Popen(['uvicorn', 'main:app', '--host', '0.0.0.0', '--port', '8080'])
|
16 |
+
|
17 |
+
try:
|
18 |
+
print("Server started. Will shutdown in 10 seconds.")
|
19 |
+
time.sleep(10) # Wait for 10 seconds
|
20 |
+
finally:
|
21 |
+
print("Shutting down server.")
|
22 |
+
# Gracefully shut down the server
|
23 |
+
server_process.send_signal(signal.SIGINT)
|
24 |
+
server_process.wait()
|
start_server.sh
CHANGED
@@ -1,16 +1,12 @@
|
|
1 |
#!/bin/bash
|
2 |
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
3 |
-
|
4 |
-
sleep 5s
|
5 |
-
ps aux | grep 'code-server' | grep -v 'grep' | awk '{print $2}' | xargs kill -9
|
6 |
sed -i '/password/d' /home/user/.config/code-server/config.yaml
|
7 |
echo "password: ${JUPYTER_TOKEN}" >>/home/user/.config/code-server/config.yaml
|
8 |
cat /home/user/.config/code-server/config.yaml
|
9 |
|
10 |
NOTEBOOK_DIR="/data"
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
ps aux | grep 'uvicorn' | grep -v 'grep' | awk '{print $2}' | xargs kill -9
|
16 |
-
code-server --bind-addr 0.0.0.0:8080 /data >/data/start.log 2>&1 &
|
|
|
1 |
#!/bin/bash
|
2 |
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
3 |
+
code-server -h
|
|
|
|
|
4 |
sed -i '/password/d' /home/user/.config/code-server/config.yaml
|
5 |
echo "password: ${JUPYTER_TOKEN}" >>/home/user/.config/code-server/config.yaml
|
6 |
cat /home/user/.config/code-server/config.yaml
|
7 |
|
8 |
NOTEBOOK_DIR="/data"
|
9 |
|
10 |
+
python main.py
|
11 |
|
12 |
+
code-server --proxy-domain atonyxu-code.hf.space --bind-addr 0.0.0.0:8080 /data >/data/start.log 2>&1 &
|
|
|
|