You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
4 years ago
|
#!/usr/bin/python3
|
||
|
|
||
|
# Launch as a eventlet.wsgi server instance.
|
||
|
|
||
|
import getopt
|
||
|
import sys
|
||
|
|
||
|
import eventlet
|
||
|
import eventlet.wsgi
|
||
|
import backend
|
||
|
|
||
4 years ago
|
from backend import store
|
||
|
|
||
|
|
||
4 years ago
|
def main(argv):
|
||
|
ssl_mode = False
|
||
|
port = 5000
|
||
|
datastore_path = "./datastore"
|
||
|
|
||
|
try:
|
||
|
opts, args = getopt.getopt(argv, "sd:p:", "purge")
|
||
|
except getopt.GetoptError:
|
||
4 years ago
|
print('backend.py -s SSL enable -p [port] -d [datastore path]')
|
||
4 years ago
|
sys.exit(2)
|
||
|
|
||
|
for opt, arg in opts:
|
||
4 years ago
|
# if opt == '--purge':
|
||
|
# Remove history, the actual files you need to delete manually.
|
||
|
# for uuid, watch in datastore.data['watching'].items():
|
||
|
# watch.update({'history': {}, 'last_checked': 0, 'last_changed': 0, 'previous_md5': None})
|
||
4 years ago
|
|
||
|
if opt == '-s':
|
||
|
ssl_mode = True
|
||
|
|
||
|
if opt == '-p':
|
||
4 years ago
|
port = int(arg)
|
||
4 years ago
|
|
||
|
if opt == '-d':
|
||
|
datastore_path = arg
|
||
|
|
||
|
|
||
4 years ago
|
|
||
|
# threads can read from disk every x seconds right?
|
||
|
# front end can just save
|
||
|
# We just need to know which threads are looking at which UUIDs
|
||
|
|
||
|
# isnt there some @thingy to attach to each route to tell it, that this route needs a datastore
|
||
4 years ago
|
app_config = {'datastore_path': datastore_path}
|
||
4 years ago
|
|
||
4 years ago
|
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'])
|
||
|
app = backend.changedetection_app(app_config, datastore)
|
||
4 years ago
|
|
||
|
if ssl_mode:
|
||
4 years ago
|
# @todo finalise SSL config, but this should get you in the right direction if you need it.
|
||
4 years ago
|
eventlet.wsgi.server(eventlet.wrap_ssl(eventlet.listen(('', port)),
|
||
|
certfile='cert.pem',
|
||
|
keyfile='privkey.pem',
|
||
|
server_side=True), app)
|
||
|
|
||
|
else:
|
||
4 years ago
|
eventlet.wsgi.server(eventlet.listen(('', port)), app)
|
||
4 years ago
|
|
||
|
|
||
4 years ago
|
if __name__ == '__main__':
|
||
|
main(sys.argv[1:])
|