-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·53 lines (49 loc) · 1.79 KB
/
main.py
File metadata and controls
executable file
·53 lines (49 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python3
# **************************************************************************** #
# #
# ::: :::::::: #
# main.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: sid-bell <sid-bell@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/10/12 15:27:18 by sid-bell #+# #+# #
# Updated: 2019/10/12 15:27:35 by sid-bell ### ########.fr #
# #
# **************************************************************************** #
import os, sys, time, signal
import threading, pickle
from daemon import loader
from daemon import init_socket
from daemon import validate
from daemon import daemon
from daemon import listener
from parse_cfgfile import validate
from daemon import builtins
import logger
from daemon import handler
from app import App
logger.init_logger()
lst,socket_addr = validate(True)
sock = init_socket.init_socket(socket_addr)
daemon.ft_daemon()
logger.log("daemon started {}\n".format(os.getpid()))
App.lst = lst
App.socket = sock
signal.signal(signal.SIGCHLD, handler.handler)
def rel(sig, frame):
builtins.reload.reload(App.socket)
signal.signal(signal.SIGHUP, rel)
sock.listen(10)
builtins.ft_startup()
while 1:
conn = None
if App.shutdown:
break
try:
conn, addr = App.socket.accept()
except:
pass
if conn:
logger.log("new Connection\n")
thr = threading.Thread(target=listener.listen, args=(conn,))
thr.start()