Browse Source

#1 webserver is replaced by twisted

pull/14/head
Rogier Neeleman 8 years ago
parent
commit
f4fe176968
  1. 6
      .gitignore
  2. 13
      README.md
  3. 2
      nfgame.py
  4. 30
      run.sh

6
.gitignore vendored

@ -6,3 +6,9 @@
# Ignoring the database # Ignoring the database
*.db *.db
# Ignoring logfiles
*.log
# Ignoring PID files
*.pid

13
README.md

@ -8,11 +8,12 @@ The next software is needed to run this game:
- Python 2.6 or higher OR - Python 2.6 or higher OR
- Python 3.3 or higher - Python 3.3 or higher
- Flask 0.11 or higher - Flask 0.11 or higher
- Twisted
You can install this as root by doing the following: You can install this as root by doing the following:
- Debian: apt-get install python-flask - Debian: apt-get install python-flask python-twisted
- FreeBSD: pkg install py27-Flask - FreeBSD: pkg install py27-Flask py27-twisted
- pip: pip install Flask - pip: pip install Flask
Watch out! Raspbian has an old version of flask! (0.10) A raspberry is perfect Watch out! Raspbian has an old version of flask! (0.10) A raspberry is perfect
@ -38,7 +39,7 @@ Please change the password!
cp nfgame.cfg-example nfgame.cfg cp nfgame.cfg-example nfgame.cfg
## Running the game ## Running the game
./run.sh ./run.sh start
The site is running on http://1.2.3.4:5000 The site is running on http://1.2.3.4:5000
You can find the administator page for cleaning the database on http://1.2.3.4:5000/admin/password You can find the administator page for cleaning the database on http://1.2.3.4:5000/admin/password
@ -46,4 +47,8 @@ You can find the administator page for cleaning the database on http://1.2.3.4:5
## Debug mode ## Debug mode
You can enable the debug mode by running: You can enable the debug mode by running:
./run.sh debug ./run.sh start debug
## Ending the game
./run.sh stop

2
nfgame.py

@ -195,4 +195,4 @@ def delete_user():
return render_template('admin_page.html') return render_template('admin_page.html')
if __name__ == '__main__': if __name__ == '__main__':
app.run() app.run(threaded=True)

30
run.sh

@ -8,13 +8,6 @@ BINDIP=0.0.0.0
export FLASK_APP=nfgame.py export FLASK_APP=nfgame.py
export NFGAME_SETTINGS=nfgame.cfg export NFGAME_SETTINGS=nfgame.cfg
# If working in debug mode
if [[ $1 == 'debug' ]]; then
export FLASK_DEBUG=1
else
export FLASK_DEBUG=0
fi
# If the database does not exists, create it. # If the database does not exists, create it.
if [ ! -f nfgame.db ]; then if [ ! -f nfgame.db ]; then
python -m flask initdb python -m flask initdb
@ -22,6 +15,27 @@ fi
if [ ! -f nfgame.cfg ]; then if [ ! -f nfgame.cfg ]; then
echo "Please copy nfgame.cfg-example to nfgame.cfg and edit the options!" echo "Please copy nfgame.cfg-example to nfgame.cfg and edit the options!"
else exit 1
fi
# If working in debug mode
if [[ $1 == 'start' ]]; then
if [[ $2 == 'debug' ]]; then
export FLASK_DEBUG=1
python -m flask run --host=$BINDIP --port=$RUNPORT python -m flask run --host=$BINDIP --port=$RUNPORT
else
if [ -f twistd.pid ]; then
echo "Game is still running."
echo "Stop the game first, or remove the file twistd.pid"
exit 1
fi
twistd web --port $RUNPORT --logfile=nfgame.log --wsgi=nfgame.app
echo "Game is started!"
echo "Have fun!"
fi
fi
if [[ $1 == 'stop' ]]; then
kill `cat twistd.pid`
echo "Game is over!"
fi fi

Loading…
Cancel
Save