-
Notifications
You must be signed in to change notification settings - Fork 0
/
OllamaUp.py
36 lines (28 loc) · 952 Bytes
/
OllamaUp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
import time
def start_ollama_server(port=8080):
try:
command = ["ollama", "run","llama3.1", "8080"]
# Ejecuta el comando en segundo plano
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
print(f"Starting Ollama server on port {port}...")
# Permite que el servidor se inicie
time.sleep(5)
# Comprobación simple de si el servidor está corriendo
if process.poll() is None:
print("Ollama server is running.")
return process
else:
print("Failed to start Ollama server.")
print("Error:", process.stderr.read())
return None
except Exception as e:
print(f"An error occurred: {e}")
return None