Courtesy of Ozan Türkyılmaz, startup.sh now takes flags for interactive and daemon mode. If no arguments are provided, default to daemon mode.
This commit is contained in:
parent
3041684ba3
commit
b1cf3f4af0
1 changed files with 56 additions and 11 deletions
67
startup.sh
67
startup.sh
|
|
@ -1,16 +1,61 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export DJANGO_SETTINGS_MODULE="settings"
|
#############################################################################
|
||||||
|
# SERVER STARTUP SCRIPT
|
||||||
|
# Sets the appropriate environmental variables and launches the server
|
||||||
|
# process. Run without flags for daemon mode.
|
||||||
|
#
|
||||||
|
# FLAGS
|
||||||
|
# -i Interactive mode
|
||||||
|
# -d Daemon mode
|
||||||
|
# -h Show help display
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
BASE_PATH=`python -c "import settings; print settings.BASE_PATH"`
|
init () {
|
||||||
mv -f $BASE_PATH/logs/evennia.log $BASE_PATH/logs/evennia.logs.old
|
## Sets environmental variables and preps the logs.
|
||||||
|
export DJANGO_SETTINGS_MODULE="settings"
|
||||||
|
BASE_PATH=`python -c "import settings; print settings.BASE_PATH"`
|
||||||
|
mv -f $BASE_PATH/logs/evennia.log $BASE_PATH/logs/evennia.logs.old
|
||||||
|
}
|
||||||
|
|
||||||
## There are several different ways you can run the server, read the
|
startup_interactive() {
|
||||||
## description for each and uncomment the desired mode.
|
## Starts the server in interactive mode.
|
||||||
|
init
|
||||||
|
echo "Starting in interactive mode..."
|
||||||
|
twistd -n --logfile=logs/evennia.log --python=src/server.py
|
||||||
|
}
|
||||||
|
|
||||||
## TODO: Make this accept a command line argument to use interactive
|
startup_daemon() {
|
||||||
## mode instead of having to uncomment crap.
|
## Starts the server in daemon mode.
|
||||||
|
init
|
||||||
|
twistd --logfile=logs/evennia.log --python=src/server.py
|
||||||
|
}
|
||||||
|
|
||||||
## Interactive mode. Good for development and debugging.
|
help_display() {
|
||||||
twistd -n --logfile=logs/evennia.log --python=src/server.py
|
echo "SERVER STARTUP SCRIPT"
|
||||||
## Stand-alone mode. Good for running games.
|
echo "Sets the appropriate environmental variables and launches the server"
|
||||||
#twistd --logfile=logs/evennia.log --python=src/server.py
|
echo "process. Run without flags for daemon mode."
|
||||||
|
echo ""
|
||||||
|
echo "FLAGS"
|
||||||
|
echo " -i Interactive mode"
|
||||||
|
echo " -d Daemon mode"
|
||||||
|
echo " -h Show help display"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
'-i')
|
||||||
|
startup_interactive
|
||||||
|
;;
|
||||||
|
'-d')
|
||||||
|
startup_daemon
|
||||||
|
;;
|
||||||
|
'--help')
|
||||||
|
help_display
|
||||||
|
;;
|
||||||
|
'-h')
|
||||||
|
help_display
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# If no argument is provided, start in daemon mode.
|
||||||
|
startup_daemon
|
||||||
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue