protected function generateRoutes()
    {
        if (defined('NAILS_STARTUP_GENERATE_APP_ROUTES') && NAILS_STARTUP_GENERATE_APP_ROUTES) {
            $oRoutesService = Factory::service('Routes');
            if (!$oRoutesService->update()) {
                throw new NailsException('Failed to generate routes_app.php. ' . $oRoutesService->lastError(), 500);
            } else {
                $oInput = Factory::service('Input');
                redirect($oInput->server('REQUEST_URI'), 'auto', 307);
            }
        }
    }