File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 18
18
from pathlib import Path
19
19
import os , os .path , json
20
20
from subprocess import Popen
21
+ import asyncio
21
22
22
23
def get_nuvolaris_config (key ):
23
24
try :
@@ -29,12 +30,18 @@ def get_nuvolaris_config(key):
29
30
return None
30
31
31
32
# serve web area
32
- def serve ():
33
+ async def serve ():
33
34
devel = get_nuvolaris_config ("devel" )
34
35
if devel is None :
35
36
devel = "nuv ide serve"
36
37
print (devel )
37
- Popen (devel , shell = True , cwd = os .environ .get ("NUV_PWD" ), env = os .environ )
38
+ #Popen(devel, shell=True, cwd=os.environ.get("NUV_PWD"), env=os.environ)
39
+ pwd = os .environ .get ("NUV_PWD" )
40
+ cmd = f"cd '{ pwd } ' ; { devel } "
41
+ proc = await asyncio .create_subprocess_shell (cmd ,
42
+ stdin = asyncio .subprocess .PIPE ,
43
+ stdout = asyncio .subprocess .PIPE ,
44
+ stderr = asyncio .subprocess .PIPE )
38
45
39
46
# build
40
47
def build ():
Original file line number Diff line number Diff line change @@ -41,15 +41,17 @@ async def redeploy():
41
41
42
42
def watch ():
43
43
loop = asyncio .get_event_loop ()
44
- #task = loop.create_task(redeploy())
45
- task = asyncio .ensure_future (redeploy ())
44
+ task1 = loop .create_task (redeploy ())
45
+ #task = asyncio.ensure_future(redeploy())
46
+ task2 = loop .create_task (serve ())
46
47
def end_loop ():
47
48
print ("Ending task." )
48
- task .cancel ()
49
+ task1 .cancel ()
50
+ task2 .cancel ()
49
51
loop .add_signal_handler (signal .SIGTERM , end_loop )
50
52
51
53
try :
52
- loop .run_until_complete (task )
54
+ loop .run_until_complete (task1 )
53
55
except asyncio .CancelledError :
54
56
pass
55
57
finally :
You can’t perform that action at this time.
0 commit comments