unclemusclez commited on
Commit
62f8c49
1 Parent(s): 4763941

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -31,7 +31,7 @@ def regenerate_pubkey(pubkey, oauth_token: gr.OAuthToken | None):
31
  generate_ollama_host_file = f"echo $(ss -natp | grep (cat ollama.pid) | awk '{{print $4}}') > ollama.host"
32
  generate_ollama_pid_file = f"echo $! > ollama.pid"
33
  ollama_pubkey = f"cat {HOME}/{hash_oauth}/.ollama/id_ed25519.pub"
34
- ollama_start = f"HOME={HOME}/{hash_oauth} ollama serve & {generate_ollama_pid_file} & sleep 5 & {generate_ollama_host_file}"
35
  ollama_stop = f"kill -9 'cat {HOME}/{hash_oauth}/ollama.pid'"
36
  delete_home = f"rm -Rf {HOME}/{hash_oauth}/.ollama"
37
 
@@ -58,8 +58,15 @@ def regenerate_pubkey(pubkey, oauth_token: gr.OAuthToken | None):
58
  print(result)
59
  if result.returncode != 0:
60
  raise Exception(f"Error starting Ollama {result.stderr}")
 
61
  print("Ollama Pubkey Obtained!")
62
 
 
 
 
 
 
 
63
 
64
  except Exception as e:
65
  return (f"Error: {e}", "error.png")
 
31
  generate_ollama_host_file = f"echo $(ss -natp | grep (cat ollama.pid) | awk '{{print $4}}') > ollama.host"
32
  generate_ollama_pid_file = f"echo $! > ollama.pid"
33
  ollama_pubkey = f"cat {HOME}/{hash_oauth}/.ollama/id_ed25519.pub"
34
+ ollama_start = f"HOME={HOME}/{hash_oauth} ollama serve & {generate_ollama_pid_file} & sleep 5"
35
  ollama_stop = f"kill -9 'cat {HOME}/{hash_oauth}/ollama.pid'"
36
  delete_home = f"rm -Rf {HOME}/{hash_oauth}/.ollama"
37
 
 
58
  print(result)
59
  if result.returncode != 0:
60
  raise Exception(f"Error starting Ollama {result.stderr}")
61
+ print(f"echo $(ss -natp | grep (cat ollama.pid) | awk '{{print $4}}')")
62
  print("Ollama Pubkey Obtained!")
63
 
64
+ result = subprocess.run(generate_ollama_host_file, shell=True, capture_output=True)
65
+ print(result)
66
+ if result.returncode != 0:
67
+ raise Exception(f"Error generating Ollama Host File {result.stderr}")
68
+ print("Ollama Host File Created!")
69
+
70
 
71
  except Exception as e:
72
  return (f"Error: {e}", "error.png")