- python2.7
- pip
- node
- npm
- virtualenv
- git
$ git clone https://github.com/15thnight/15thnight
$ cd 15thnight
$ virtualenv venv
$ echo "export PYTHONPATH=$(pwd)" >> venv/bin/activate
$ source venv/bin/activate
$ pip install -r requirements.txt
$ cd client
$ npm install
$ ./node_modules/.bin/webpack && cd ..
At this point, you will have the project downloaded along with the python packages.
To customize the entire default configuration, you can simply copy the distribution config file to config.py
and then edit config.py
:
$ cp configdist.py config.py
$ vim config.py
Another option is to import all the default settings and only overwrite certain settings. Here is an example of a minimal config.py file that imports default values and sets the database to a MySQL connection and sets the address:
from configdist import *
DATABASE_URL = 'mysql://db_user:db_pass@db_host/db_name'
# SERVER_NAME must NOT have a protocol prefix (no http/https)
SERVER_NAME = 'localhost:5000'
The DATABASE_URL
string in the config file determines the engine and settings for the database connection. The default is a SQLite connection string that creates a test.db
file. NOTE: migrations are not possible with SQLite
Postgres, MySQL and SQLite databases are supported.
Example postgres connection string:
postgres://db_user:db_pass@db_host/db_name
In order to use MySQL, MySQL-python must be installed:
pip install MySQL-python
Example MySQL connection string:
mysql://db_user:db_pass@db_host/db_name
The database tables can either be created with migrations (recommended) or without.
For MySQL and Postgres databases, the database must be created first before creating the tables:
CREATE DATABASE db_name
To create the database tables via migrations, MySQL or PostgreSQL must be used as the database. This command will create the database tables and is also used to migrate the tables if there are any new migrations:
$ alembic upgrade head
For more information on how the project migrations work, refer to the alembic documentation.
For simple development, such as with sqlite, create the database tables with the following command:
$ ./manage.py create_db
Note that migrating the database tables to future versions is not possible when they are created with this command.
To use SMS features, a Twilio account is required. Follow these steps to set up twilio:
- Sign up for an account at twilio.com.
- At the dashboard page, locate the
Account SID
andAuth Token
values and set them inconfig.py
. They correlate to theTWILIO_ACCOUNT_SID
andTWILIO_ACCONT_AUTH_TOKEN
settings, respectfully. - Click on the # button in the upper left to be taken to the phone numbers page.
- Buy a phone number that has SMS capabilities and set the
TWILIO_FROM_NUMBER
in the config to that number. Make sure the number is in the format+1XXXXXXXXXX
.
Twilio allows use of the twilio number and SMS capabilities for a little while as a trial account without paying.
$ ./manage.py create_user <email> <password> <role>
Example:
$ ./manage.py create_user [email protected] password admin
Seed the database with the test users (refer to the source code for the user details):
$ ./manage.py seed_db
Begin by running celery:
$ celery -A _15thnight.queue worker
Then start up the development web server with live reloading of python code changes (r
flag) and debug output (d
flag):
$ ./manage.py runserver -dr
Go to localhost:5000 in your browser.
To host the project from a production environment, first follow the instructions under Standard Development Installation and set up a database.
- Apache or nginx
- WSGI
- MySQL or PostgreSQL (recommended)
- Redis or RabbitMQ (recommended)
./setup_celery.sh
# Change the 3 to the concurrency level desired
sed \{"s?PROJECT_PATH?$(pwd)?g; s?THREAD_COUNT?3?g;"\} celeryd.template > celeryd.conf
mv celeryd.conf /etc/default/celeryd
cp celeryd.init /etc/init.d/celeryd
useradd -M -r -s /bin/false celery
Create a WSGI file for Apache/nginx:
$ sed "s?PROJECT_PATH?$(pwd)?g" 15thnight.wsgi.template > 15thnight.wsgi
Create the apache config (this config assumes you have a _15thnight user added to a _15thnight group that has access to the project directory):
$ sed "s?PROJECT_PATH?$(pwd)?g" 15thnight.apache.template