Add config to run as service behind nginx

pull/1/head
Raphaël Vinot 2017-08-12 20:12:14 +02:00
parent aa659234bb
commit ca5d07b8b8
7 changed files with 78 additions and 2 deletions

View File

@ -59,7 +59,6 @@ And restart xdm:
service xdm restart service xdm restart
``` ```
# Installation of scrapysplashwrapper # Installation of scrapysplashwrapper
You need a running splash instance, preferably on docker: https://splash.readthedocs.io/en/stable/install.html You need a running splash instance, preferably on docker: https://splash.readthedocs.io/en/stable/install.html
@ -80,3 +79,37 @@ pew toggleglobalsitepackages # PyQt4 is not easily installable in a virtualenv
pip install -r requirements.txt pip install -r requirements.txt
pip install -e . pip install -e .
``` ```
# Run the app locally
```bash
export DISPLAY=:0
export FLASK_APP=lookyloo
flask run
```
## With a reverse proxy (Nginx)
```bash
pip install uwsgi
```
### Config files
You have to configure the two following files:
* `etc/nginxsites-available/lookyloo`
* `etc/systemd/system/lookyloo.service`
And copy them to the appropriate directories and run the following command:
`sudo ln -s /etc/nginx/sites-available/lookyloo /etc/nginx/sites-enabled`
Make sure everything is working:
```bash
sudo systemctl start lookyloo
sudo systemctl enable lookyloo
sudo nginx -t
# If it is cool:
sudo service restart nginx
```

0
__init__.py Normal file
View File

View File

@ -0,0 +1,9 @@
server {
listen 80;
server_name server_domain_or_IP;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/<CHANGE_ME>/lookyloo/lookyloo.sock;
}
}

View File

@ -0,0 +1,16 @@
[Unit]
Description=uWSGI instance to serve lookyloo
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/home/<CHANGE_ME>/lookyloo
Environment="PATH=/home/<CHANGE_ME>/<MY_VIRTUALENV_PATH>/bin"
ExecStart=/home/<CHANGE_ME>/<MY_VIRTUALENV_PATH>/bin/uwsgi --ini lookyloo.ini
Environment=DISPLAY=:0
Environment=FLASK_APP=lookyloo
[Install]
WantedBy=multi-user.target

11
lookyloo.ini Normal file
View File

@ -0,0 +1,11 @@
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = lookyloo.sock
chmod-socket = 660
vacuum = true
die-on-term = true

View File

@ -5,7 +5,7 @@ import json
from har2tree import CrawledTree, hostname_treestyle from har2tree import CrawledTree, hostname_treestyle
from scrapysplashwrapper import crawl from scrapysplashwrapper import crawl
from ete3_webserver import NodeActions, WebTreeHandler from .ete3_webserver import NodeActions, WebTreeHandler
from flask import Flask, render_template, request from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap

7
wsgi.py Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from lookyloo import app
if __name__ == "__main__":
app.run()