Spaces:
Sleeping
Sleeping
abubasith86
commited on
Commit
Β·
ef11509
1
Parent(s):
4b421e2
test
Browse files
deploy.py
CHANGED
@@ -3,22 +3,28 @@ import shutil
|
|
3 |
import subprocess
|
4 |
|
5 |
APP_DIR = "/app"
|
6 |
-
TMP_DIR = "/tmp/repo_clone"
|
7 |
REPO_URL = "https://github.com/abubasith456/Node-WLA.git"
|
8 |
|
9 |
|
10 |
def remove_app_directory():
|
11 |
if os.path.exists(APP_DIR):
|
12 |
print("β οΈ Removing existing app directory...")
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def clone_repository():
|
17 |
print("π Cloning repository...")
|
18 |
-
|
19 |
-
shutil.rmtree(APP_DIR, ignore_errors=True)
|
20 |
-
|
21 |
-
subprocess.run(["git", "clone", REPO_URL, TMP_DIR], check=True)
|
22 |
|
23 |
|
24 |
def install_dependencies():
|
@@ -28,12 +34,13 @@ def install_dependencies():
|
|
28 |
|
29 |
def start_application():
|
30 |
print("π Starting application...")
|
31 |
-
subprocess.
|
32 |
|
33 |
|
34 |
def main():
|
35 |
print("π Deployment started...")
|
36 |
remove_app_directory()
|
|
|
37 |
clone_repository()
|
38 |
install_dependencies()
|
39 |
start_application()
|
|
|
3 |
import subprocess
|
4 |
|
5 |
APP_DIR = "/app"
|
|
|
6 |
REPO_URL = "https://github.com/abubasith456/Node-WLA.git"
|
7 |
|
8 |
|
9 |
def remove_app_directory():
|
10 |
if os.path.exists(APP_DIR):
|
11 |
print("β οΈ Removing existing app directory...")
|
12 |
+
try:
|
13 |
+
shutil.rmtree(APP_DIR)
|
14 |
+
except PermissionError:
|
15 |
+
print("β οΈ Permission denied. Changing ownership and retrying...")
|
16 |
+
subprocess.run(["chown", "-R", str(os.getuid()), APP_DIR], check=False)
|
17 |
+
shutil.rmtree(APP_DIR, ignore_errors=True)
|
18 |
+
|
19 |
+
|
20 |
+
def create_app_directory():
|
21 |
+
print("π Creating app directory...")
|
22 |
+
os.makedirs(APP_DIR, exist_ok=True)
|
23 |
|
24 |
|
25 |
def clone_repository():
|
26 |
print("π Cloning repository...")
|
27 |
+
subprocess.run(["git", "clone", REPO_URL, APP_DIR], check=True)
|
|
|
|
|
|
|
28 |
|
29 |
|
30 |
def install_dependencies():
|
|
|
34 |
|
35 |
def start_application():
|
36 |
print("π Starting application...")
|
37 |
+
subprocess.run(["npm", "start"], cwd=APP_DIR, check=True)
|
38 |
|
39 |
|
40 |
def main():
|
41 |
print("π Deployment started...")
|
42 |
remove_app_directory()
|
43 |
+
create_app_directory()
|
44 |
clone_repository()
|
45 |
install_dependencies()
|
46 |
start_application()
|