Skip to content

Commit

Permalink
Merge branch 'master' of github.com:merforga/gw2raidar
Browse files Browse the repository at this point in the history
  • Loading branch information
Goran Topic committed Oct 30, 2017
2 parents 16d00b5 + 184732f commit 4eb6e8e
Show file tree
Hide file tree
Showing 199 changed files with 18,913 additions and 513 deletions.
30 changes: 27 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# compiled Python files
*.pyc
db.sqlite3
TestLogs
.idea

# dev database
/db.sqlite3

# test data
/TestLogs

# soloraidar output
/Output

# IntelliJ IDEA
.idea

# iPython
.ipynb_checkpoints
*.ipynb

# Local settings, possibly with sensitive info
# (copy from `gw2raidar/settings_local.py.example`)
/gw2raidar/settings_local.py

# result of `python3 manage.py collectstatic --noinput`
/static

# secret stuff
/credentials
134 changes: 134 additions & 0 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
How to pull off the WSGI+PostgreSQL deploy

```
apt install python3-dev python3-pip apache2 apache2-dev git postgresql-9.6
```

Create the postgres user

```
sudo -u postgres psql
CREATE ROLE [user] LOGIN PASSWORD '[password]';
CREATE DATABASE [database] WITH OWNER = [user];
```

Download `mod_wsgi` source

```
sudo su -
wget [mod_wsgi_url]
tar xzf [mod_wsgi].tar.gz
cd [mod_wsgi_dir]
./configure --with-python=`which python3`
make
make install
```


create `/etc/apache2/mods-available/wsgi.load`:

```
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIApplicationGroup %{GLOBAL}
```

Then

```
a2enmod wsgi
certbot --apache
```

Assume the app will be called `gw2r-test`.
Put the following into `/etc/apache2/sites-enabled/000-default-le-ssl.conf`, somewhere inside `VirtualHost`:

```
Alias /gw2r-test/static/ /var/www/apps/gw2r-test/static/
WSGIDaemonProcess gw2r-test processes=2 threads=15 display-name=%{GROUP} python-path=/var/www/apps/gw2r-test
WSGIProcessGroup gw2r-test
WSGIScriptAlias /gw2r-test /var/www/apps/gw2r-test/gw2raidar/wsgi.py process-group=gw2r-test
<Directory /var/www/apps/gw2r-test/gw2raidar>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
```

Get GW2Raidar (assuming `develop` branch):

```
mkdir /var/www/apps
cd /var/www/apps
git clone [email protected]:merforga/gw2raidar.git -b develop gw2r-test
cd gw2r-test
cp gw2raidar/settings_local.py.example gw2raidar/settings_local.py
```

Edit `gw2raidar/settings_local.py` to prepare for WSGI:

```
DEBUG = False
# When DEBUG is False (must for production),
# this needs to be set for the app's host, like so:
ALLOWED_HOSTS = ['139.162.68.156']
# This needs to be secret and can't be committed to the repository
SECRET_KEY = '[secretkey]'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'gw2r_test',
'USER': 'gw2raidar',
'PASSWORD': '[password]',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
EMAIL_SUBJECT_PREFIX = '[gw2raidar] '
# normal mail (like password reset), to users
DEFAULT_FROM_EMAIL = '[email protected]'
# error emails, to admins
SERVER_EMAIL = '[email protected]' #
# the abovementioned admins
# ADMINS = [
# ('Admin1', '[email protected]'),
# ('Admin2', '[email protected]'),
# ]
# SMTP server
# You can use a fake SMTPD that will print any "sent" emails to console:
#
# python -m smtpd -n -c DebuggingServer localhost:1025
#
# This would require 'EMAIL_PORT = 1025`.
# Obviously, in production, point it to a real SMTP server, where the default
# `EMAIL_PORT = 25` should be okay.
EMAIL_HOST = 'localhost'
# EMAIL_PORT = 1025
STATIC_URL = '/gw2r-test/static/'
STATIC_ROOT = '/var/www/apps/gw2r-test/static/'
```


# Adding a user

```
useradd -m amadan
passwd amadan
mkdir ~amadan/.ssh
cd ~amadan/.ssh
cat > authorized_hosts
chown amadan:amadan . authorized_hosts
chmod og-rwx . authorized_hosts
usermod -aG sudo amadan
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ GW2 Raidar
Quickstart
----------

* Install Python 3
* `pip3 install django`
* Install Python 3 and pip3
* `pip3 install django pandas requests django-taggit psycopg2 google-api-python-client`
* `python3 manage.py migrate`
* `python3 manage.py createsuperuser`
* `python3 manage.py runserver`
* Browse to http://localhost:8000/

To generate statistics, use `python3 manage.py restat [-f] [-v{0,1,2,3}]`.

To process new uploads, use `python3 manage.py process_uploads [-v{0,1,2,3}]`.
Loading

0 comments on commit 4eb6e8e

Please sign in to comment.