1 socket = require "socket"
10 function civet.start(docroot)
11 -- TODO: use a property
12 docroot = docroot or 'ci/test/01_basic/docroot'
13 assert(io.popen('./civetweb'
14 .. " -listening_ports " .. civet.port
15 .. " -document_root " .. docroot
16 .. " > /dev/null 2>&1 &"
18 -- wait until the server answers
19 for i=1,civet.max_retry do
20 local s = socket.connect('127.0.0.1', civet.port)
25 socket.select(nil, nil, civet.start_delay) -- sleep
30 os.execute('killall civetweb')
31 -- wait until the server port closes
32 for i=1,civet.max_retry do
33 local s = socket.connect('127.0.0.1', civet.port)
38 socket.select(nil, nil, civet.start_delay) -- sleep