-
Notifications
You must be signed in to change notification settings - Fork 15
/
run.py
executable file
·45 lines (36 loc) · 1.29 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
#!/usr/bin/env python
from gevent import monkey
from socketio.server import SocketIOServer
import django.core.handlers.wsgi
import os
import sys
from threading import Thread
monkey.patch_all()
try:
from malwarez import settings
except ImportError:
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
PORT = 80
os.environ['DJANGO_SETTINGS_MODULE'] = 'malwarez.settings'
application = django.core.handlers.wsgi.WSGIHandler()
#sys.path.insert(0, os.path.join(settings.PROJECT_ROOT, "apps"))
if __name__ == '__main__':
server = None
print 'Listening on http://127.0.0.1:%s and on port 843 (flash policy server)' % PORT
server = SocketIOServer(('', PORT), application, resource="socket.io")
print "Ctrl+C to stop..."
def start():
global server
server.serve_forever()
t = Thread(target=start)
t.daemon = True
t.start()
try:
t.join()
except KeyboardInterrupt:
print 'stopping server'
server.stop()
print 'waiting thread'
t.join()
print 'Bye!'