} if daemonize: log = open(os.path.join(settings.LOG_DIR, '%s.log' % (service,)), 'w+') kwargs.update({ 'pidfile': os.path.join(settings.RUN_DIR, '%s.pid' % (service,)), 'stderr': log, 'stdout': log, }) proc = daemon.Daemon(**kwargs) return proc @options( opt('--daemon', '-d', action='store_true', default=False, dest='daemonize'), opt('--no-daemon', '-f', action='store_false', default=False, dest='daemonize'), opt('--debug', action='store_true', default=False, dest='debug'), ) @consume_args def start(args, daemonize=False, debug=False): from localshop.conf import settings if not os.path.exists(settings.LOG_DIR): os.makedirs(settings.LOG_DIR) if not os.path.exists(settings.RUN_DIR): os.makedirs(settings.RUN_DIR) # Ensure we force an environment upgrade before we start the server
from django.core.management import call_command from django.conf import settings from localshop.commands.utils import options, opt @options( opt('--interactive', default=False, action='store_true'), opt('--delete-ghost-migrations', default=True, dest='delete_ghosts'), ) def upgrade(interactive=True, delete_ghosts=True): call_command('syncdb', database='default', interactive=interactive) if 'south' in settings.INSTALLED_APPS: call_command('migrate', database='default', interactive=interactive, delete_ghosts=delete_ghosts)