forked from w5teams/w5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·70 lines (56 loc) · 2.37 KB
/
run.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# encoding:utf-8
import gevent.monkey
gevent.monkey.patch_all()
import sys
import platform
def w5_info(**kwargs):
print(" ##@&$||;..!||||||||||;;||||||||%$@##@")
print(" #@$%||||!` .;|||||;. `:!||||||$@@@")
print(" @$%||||||||!` `!||||$@&")
print(" &$||||||||||!. :|||||%$$")
print(" $%||||||||||` `!||||||$$")
print(" $%|||||||||;. :|||||$$")
print(" $%||||||||!. .;|||$$")
print(" &$||||||||; .!|:. `!%$$")
print(" @$%||||||||;. .:|||!' .!&&")
print(" #@$|||||||||||||||!` '%@@")
print(" ##@$%|||||||||||!` :%@#@")
print(" ###@&$||||||||!` !&###@")
print(" #####@&&%||||:. `%&#####@")
print(" ########&&&%: W5 SOAR '$&@#######@ v{version}".format(version="0.5.5"))
print("=============================================")
print("* Web : https://w5.io")
print("* Github : https://github.com/w5hub/w5")
print("=============================================")
if platform.system() == 'Windows':
print("* Running on http://{host}:{port}/ (Press CTRL+C to quit)".format(host=kwargs["host"],
port=kwargs["port"]))
def start_w5(**kwargs):
w5_info(host=kwargs["host"], port=kwargs["port"])
if platform.system() != 'Windows':
from core import start
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
server = pywsgi.WSGIServer((kwargs["host"], kwargs["port"]), start, handler_class=WebSocketHandler)
server.serve_forever()
else:
import multiprocessing
from gunicorn.app.wsgiapp import run as start_http
workers = multiprocessing.cpu_count() * 2 + 1
sys.argv.append("-k")
sys.argv.append("flask_sockets.Worker")
sys.argv.append("-b")
sys.argv.append(kwargs["host"] + ":" + str(kwargs["port"]))
sys.argv.append("-w")
sys.argv.append(str(workers))
sys.argv.append("-t")
sys.argv.append("60")
sys.argv.append("--threads")
sys.argv.append("2")
sys.argv.append("core:start")
start_http()
if __name__ == '__main__':
host = '0.0.0.0'
port = 8888
start_w5(host=host, port=port)