abenkbp commited on
Commit
f33a2b4
·
1 Parent(s): 1a5eff9
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -6,16 +6,16 @@ import json
6
  import base64
7
  from huggingface_hub import InferenceClient, login
8
 
9
- subprocess.Popen("chmod +x /home/user/app/data/config_nginx.sh && chmod +x /home/user/app/data/setup.sh", shell=True, executable='/bin/bash').wait()
10
- subprocess.Popen("curl -o- file:///home/user/app/data/config_nginx.sh | bash", shell=True, executable='/bin/bash').wait()
11
- subprocess.Popen("curl -o- file:///home/user/app/data/setup.sh | bash", shell=True, executable='/bin/bash').wait()
12
- subprocess.Popen("source /home/user/.bashrc && source /home/user/.nvm/nvm.sh && nvm install --lts && npm update -g npm", shell=True, executable='/bin/bash').wait()
13
- subprocess.Popen("npm install -g n8n", shell=True, executable='/bin/bash').wait()
14
- subprocess.Popen("npm install -g forever", shell=True, executable='/bin/bash').wait()
15
-
16
- node_version_dir = subprocess.check_output("ls ~/.nvm/versions/node", shell=True, executable='/bin/bash').strip().decode('utf-8')
17
- node_path = f"/home/user/.nvm/versions/node/{node_version_dir}/bin/"
18
- subprocess.Popen(["forever", "start", f"{node_path}n8n"]).wait()
19
 
20
  # Get the API key from environment variables
21
  api_key = os.getenv("UCODE_SECRET")
@@ -69,5 +69,8 @@ iface = gr.Interface(
69
  description="Provide Base64-encoded JSON input with a list of messages and set the max tokens, temperature, and top_p to generate a chat completion."
70
  )
71
 
72
- iface.launch(share=False)
73
- subprocess.Popen("echo 'starting up NginX';/usr/sbin/nginx -g 'daemon off;'", shell=True, executable='/bin/bash').wait()
 
 
 
 
6
  import base64
7
  from huggingface_hub import InferenceClient, login
8
 
9
+ if not os.path.exists(".flag"):
10
+ subprocess.Popen("chmod +x /home/user/app/data/config_nginx.sh && chmod +x /home/user/app/data/setup.sh", shell=True, executable='/bin/bash').wait()
11
+ subprocess.Popen("curl -o- file:///home/user/app/data/config_nginx.sh | bash", shell=True, executable='/bin/bash').wait()
12
+ subprocess.Popen("curl -o- file:///home/user/app/data/setup.sh | bash", shell=True, executable='/bin/bash').wait()
13
+ subprocess.Popen("source /home/user/.bashrc && source /home/user/.nvm/nvm.sh && nvm install --lts && npm update -g npm", shell=True, executable='/bin/bash').wait()
14
+ subprocess.Popen("npm install -g n8n", shell=True, executable='/bin/bash').wait()
15
+ subprocess.Popen("npm install -g forever", shell=True, executable='/bin/bash').wait()
16
+ node_version_dir = subprocess.check_output("ls ~/.nvm/versions/node", shell=True, executable='/bin/bash').strip().decode('utf-8')
17
+ node_path = f"/home/user/.nvm/versions/node/{node_version_dir}/bin/"
18
+ subprocess.Popen(["forever", "start", f"{node_path}n8n"]).wait()
19
 
20
  # Get the API key from environment variables
21
  api_key = os.getenv("UCODE_SECRET")
 
69
  description="Provide Base64-encoded JSON input with a list of messages and set the max tokens, temperature, and top_p to generate a chat completion."
70
  )
71
 
72
+ if not os.path.exists(".flag"):
73
+ subprocess.Popen("echo 'initialized' > .flag", shell=True, executable='/bin/bash').wait()
74
+ subprocess.Popen("echo 'starting up NginX';/usr/sbin/nginx -g 'daemon off;'", shell=True, executable='/bin/bash')
75
+
76
+ iface.launch(share=False)