]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/ci/test/civet.lua
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / ci / test / civet.lua
1 socket = require "socket"
2
3 local civet = {}
4
5 -- default params
6 civet.port=12345
7 civet.max_retry=100
8 civet.start_delay=0.1
9
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 &"
17 ))
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)
21 if s then
22 s:close()
23 break
24 end
25 socket.select(nil, nil, civet.start_delay) -- sleep
26 end
27 end
28
29 function civet.stop()
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)
34 if not s then
35 break
36 end
37 s:close()
38 socket.select(nil, nil, civet.start_delay) -- sleep
39 end
40 end
41
42 return civet