Esempio n. 1
0
def httpd_start(folder, port):
	folder = params.convert(folder, convert=os.path.realpath, check=os.path.exists)
	port = params.convert(port, convert=int, gte=1, lt=2**16)
	netstat.checkPortFree(port)
	pid = spawnDaemon(["busybox", "httpd", "-f", "-p", str(port)], cwd=folder)
	try:
		wait.waitFor(lambda :netstat.isPortUsedBy(port, pid), failCond=lambda :not proc.isAlive(pid))
		return pid
	except wait.WaitError:
		proc.autoKill(pid, group=True)
		raise
Esempio n. 2
0
def start(port, command):
	port = params.convert(port, convert=int, gte=1, lt=2**16)
	command = params.convert(command, convert=list)
	netstat.checkPortFree(port, tcp=True, ipv4=True)
	pid = spawnDaemon(["tcpserver", "-qHRl", "0",  "0", str(port)] + command)
	try:
		wait.waitFor(lambda :netstat.isPortUsedBy(port, pid), failCond=lambda :not proc.isAlive(pid))
		return pid
	except wait.WaitError:
		proc.autoKill(pid, group=True)
		raise
Esempio n. 3
0
def start(port, vncport, sslcert=None):
	port = params.convert(port, convert=int, gte=1, lt=2**16)
	vncport = params.convert(vncport, convert=int, gte=1, lt=2**16)
	sslcert = params.convert(sslcert, convert=str, null=True, check=os.path.exists)
	WebsockifyError.check(not netstat.isPortFree(vncport), WebsockifyError.CODE_DEST_PORT_FREE, "Destination port is free", {"port": vncport})
	netstat.checkPortFree(port, tcp=True, ipv4=True)
	pid = spawnDaemon(["websockify", "0.0.0.0:%d" % port, "localhost:%d" % vncport] + (["--cert=%s" % sslcert] if sslcert else []))
	try:
		wait.waitFor(lambda :netstat.isPortUsedBy(port, pid), failCond=lambda :not proc.isAlive(pid))
		return pid
	except wait.WaitError:
		proc.autoKill(pid, group=True)
		raise
Esempio n. 4
0
def httpd_stop(pid):
	proc.autoKill(pid, group=True)
	BusyboxError.check(not proc.isAlive(pid), BusyboxError.CODE_STILL_RUNNING, "Failed to stop http server")
Esempio n. 5
0
def stop(pid):
	proc.autoKill(pid)
	VpnCloudError.check(not proc.isAlive(pid), VpnCloudError.CODE_STILL_RUNNING, "Failed to stop vpncloud")
Esempio n. 6
0
File: qm.py Progetto: GLab/ToMaTo
def stopVnc(pid, websockifyPid=None):
	proc.autoKill(pid, group=True)
	QMError.check(not proc.isAlive(pid), QMError.CODE_STILL_RUNNING, "Failed to stop socat")
	if websockifyPid:
		websockify.stop(websockifyPid)
Esempio n. 7
0
def stop(pid):
	proc.autoKill(pid, group=True)
	TcpserverError.check(not proc.isAlive(pid), TcpserverError.CODE_STILL_RUNNING, "Failed to stop tcpserver")
Esempio n. 8
0
File: ipspy.py Progetto: GLab/ToMaTo
def stop(pid):
    proc.autoKill(pid, group=True)
    IpspyError.check(not proc.isAlive(pid), IpspyError.CODE_STILL_RUNNING, "Failed to stop ipspy")
Esempio n. 9
0
def stop(pid):
	proc.autoKill(pid, group=True)
	WebsockifyError.check(not proc.isAlive(pid), WebsockifyError.CODE_STILL_RUNNING, "Failed to stop websockify")