sohojoe commited on
Commit
57d3a27
1 Parent(s): 5393a41

auto start ray and charles actor

Browse files
Files changed (2) hide show
  1. app.py +9 -1
  2. charles_actor.py +5 -0
app.py CHANGED
@@ -29,13 +29,21 @@ webrtc_ctx = None
29
  # Initialize Ray
30
  import ray
31
  if not ray.is_initialized():
 
 
 
 
 
32
  # Try to connect to a running Ray cluster
33
  ray_address = os.getenv('RAY_ADDRESS')
34
  if ray_address:
35
  ray.init(ray_address, namespace="project_charles")
36
  else:
37
  ray.init(namespace="project_charles")
38
-
 
 
 
39
 
40
 
41
  async def main():
 
29
  # Initialize Ray
30
  import ray
31
  if not ray.is_initialized():
32
+ import subprocess
33
+ try:
34
+ subprocess.check_output(["ray", "start", "--head"])
35
+ except Exception as e:
36
+ print (e)
37
  # Try to connect to a running Ray cluster
38
  ray_address = os.getenv('RAY_ADDRESS')
39
  if ray_address:
40
  ray.init(ray_address, namespace="project_charles")
41
  else:
42
  ray.init(namespace="project_charles")
43
+ import platform
44
+ print (f"platform:{platform.system()}")
45
+ if platform.system() == 'Linux':
46
+ charles_actor_proc = subprocess.Popen(["python3", "charles_actor.py"])
47
 
48
 
49
  async def main():
charles_actor.py CHANGED
@@ -186,6 +186,11 @@ async def main():
186
  if not ray.is_initialized():
187
  # Try to connect to a running Ray cluster
188
  ray_address = os.getenv('RAY_ADDRESS')
 
 
 
 
 
189
  if ray_address:
190
  ray.init(ray_address, namespace="project_charles")
191
  else:
 
186
  if not ray.is_initialized():
187
  # Try to connect to a running Ray cluster
188
  ray_address = os.getenv('RAY_ADDRESS')
189
+ import subprocess
190
+ try:
191
+ subprocess.check_output(["ray", "start", "--head"])
192
+ except Exception as e:
193
+ print (e)
194
  if ray_address:
195
  ray.init(ray_address, namespace="project_charles")
196
  else: