3 import System
.Threading
4 import System
.Diagnostics
6 # The command to launch the web server
8 # Determine if the web server has to be restarted
10 SERVER_RESTART
= argv
[1] == 'restart'
11 # Arguments to send to with the server command
12 SERVER_ARGUMENTS
= join(argv
[2:], ' ')
14 # Arguments to send to nant when building
15 # Typically the target that builds and some arguments
16 NANT_ARGUMENTS
= 'build -nologo -q'
18 # Time to wait before watching for changes again
19 REBUILD_DELAY
= 1000 #ms
22 ######## Stop editing here unless you're a damn cool Boo hacker ########
23 watcher
= FileSystemWatcher(Directory
.GetCurrentDirectory(), "*.cs")
24 watcher
.IncludeSubdirectories
= true
25 print "Starting live server process, hit CTRL+C to stop"
27 serverProcess
as Process
31 print "nant ${NANT_ARGUMENTS}"
32 buildProcess
= shellp('nant', NANT_ARGUMENTS
)
33 buildProcess
.WaitForExit()
36 if (buildProcess
.ExitCode
== 0):
37 if SERVER_RESTART
or serverProcess
== null:
38 # Try to stop the server
39 if (serverProcess
!= null):
44 serverProcess
.WaitForExit()
46 print "${SERVER_CMD} ${SERVER_ARGUMENTS}"
47 serverProcess
= shellp(SERVER_CMD
, SERVER_ARGUMENTS
)
49 print "Build failed! Errors:"
51 print buildProcess
.StandardOutput
.ReadToEnd()
54 Thread
.CurrentThread
.Sleep(REBUILD_DELAY
)
55 change
= watcher
.WaitForChanged(WatcherChangeTypes
.All
)
56 print "File change detected (${change.Name})"