1010import time
1111import webbrowser
1212
13+ import requests
1314import toml
1415from python_on_whales import DockerClient
1516
@@ -94,9 +95,9 @@ def prepare_env():
9495 or "Y"
9596 )
9697
97- if keep_updated .lower () != "n" and config [ "llmstack" ][ "admin_email" ] :
98+ if keep_updated .lower () != "n" :
9899 # Add the user to the mailing list
99- pass
100+ webbrowser . open ( "https://forms.gle/UKQ9rumczFDvwVmg7" )
100101
101102 with open (config_path , "w" ) as f :
102103 toml .dump (config , f )
@@ -146,32 +147,35 @@ def wait_for_server(llmstack_environment, timeout):
146147 start_time = time .time ()
147148 while True :
148149 try :
149- import requests
150-
150+ print (
151+ "\n Waiting for LLMStack server to be up..." ,
152+ end = "" ,
153+ )
151154 resp = requests .get (
152155 f'http://{ llmstack_environment ["LLMSTACK_HOST" ]} :{ llmstack_environment ["LLMSTACK_PORT" ]} ' ,
153156 )
154157 if resp .status_code < 400 :
155158 break
156- print (
157- "Waiting for LLMStack server to be up..." ,
158- )
159+
159160 time .sleep (2 + (random .randint (0 , 1000 ) / 1000 ))
160161
161162 # If we have waited for more than 3 minutes, exit
162163 if time .time () - start_time > timeout :
163- raise Exception ("Timeout" )
164- except Exception :
164+ raise TimeoutError ("Timeout waiting for LLMStack server to be up. " )
165+ except TimeoutError :
165166 print (
166- "Failed to connect to LLMStack server. Exiting..." ,
167+ "\n Failed to connect to LLMStack server. Exiting..." ,
167168 )
168- logs (follow = False )
169+ print_compose_logs (follow = False )
169170 stop (1 )
171+ except Exception :
172+ time .sleep (2 + (random .randint (0 , 1000 ) / 1000 ))
173+ continue
170174
171175 webbrowser .open (f'http://{ llmstack_environment ["LLMSTACK_HOST" ]} :{ llmstack_environment ["LLMSTACK_PORT" ]} ' )
172176
173177
174- def logs (follow = True , stream = True ):
178+ def print_compose_logs (follow = True , stream = True ):
175179 """Get logs for LLMStack server"""
176180 docker_client = DockerClient (
177181 compose_project_name = "llmstack" ,
@@ -283,6 +287,7 @@ def signal_handler(sig, frame):
283287
284288 if args .port is not None :
285289 llmstack_environment ["LLMSTACK_PORT" ] = args .port
290+ os .environ ["LLMSTACK_PORT" ] = args .port
286291
287292 protocol = "http"
288293
@@ -300,7 +305,7 @@ def signal_handler(sig, frame):
300305 if not args .no_browser :
301306 wait_for_server (llmstack_environment , args .timeout )
302307
303- print (f"LLMStack server is running at { llmstack_environment ['SITE_URL' ]} ." )
308+ print (f"\n \n LLMStack server is running at { llmstack_environment ['SITE_URL' ]} ." )
304309
305310 # If running in detached mode, return
306311 if args .detach :
@@ -313,7 +318,7 @@ def signal_handler(sig, frame):
313318 signal .signal (signal .SIGINT , signal_handler )
314319
315320 if not args .quiet or args .command == "logs" :
316- logs ()
321+ print_compose_logs ()
317322
318323 # Block the main thread until a signal is received
319324 if "windows" in platform .platform ().lower ():
0 commit comments