How to use the uwsgi.reload function in uWSGI

To help you get started, we’ve selected a few uWSGI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GeoNode / geonode / geonode / monitoring / models.py View on Github external
def do_reload():
    """
    This will reload uwsgi if it's available
    """
    try:
        import uwsgi
        uwsgi.reload()
        return
    except ImportError:
        pass
github LPgenerator / django-db-mailer / dbmail / admin.py View on Github external
def auto_reload(request):
        if defaults.WSGI_AUTO_RELOAD is True:
            env = request.environ.get
            if env('mod_wsgi.process_group') and env('SCRIPT_FILENAME'):
                if int(env('mod_wsgi.script_reloading', 0)):
                    try:
                        if os.path.exists(env('SCRIPT_FILENAME')):
                            os.utime(env('SCRIPT_FILENAME'), None)
                    except OSError:
                        pass

        if defaults.UWSGI_AUTO_RELOAD is True:
            try:
                import uwsgi

                uwsgi.reload()
            except ImportError:
                pass
github 8planes / mirosubs / libs / rosetta / views.py View on Github external
# Try auto-reloading via the WSGI daemon mode reload mechanism
                    if  rosetta_settings.WSGI_AUTO_RELOAD and \
                        request.environ.has_key('mod_wsgi.process_group') and \
                        request.environ.get('mod_wsgi.process_group',None) and \
                        request.environ.has_key('SCRIPT_FILENAME') and \
                        int(request.environ.get('mod_wsgi.script_reloading', '0')):
                            try:
                                os.utime(request.environ.get('SCRIPT_FILENAME'), None)
                            except OSError:
                                pass
                    # Try auto-reloading via uwsgi daemon reload mechanism
                    if rosetta_settings.UWSGI_AUTO_RELOAD:
                        try:
                            import uwsgi
                            # pretty easy right?
                            uwsgi.reload()
                        except:
                            # we may not be running under uwsgi :P
                            pass
                        
                except:
                    request.session['rosetta_i18n_write'] = False
                
                request.session['rosetta_i18n_pofile']=rosetta_i18n_pofile
                
                # Retain query arguments
                query_arg = ''
                if 'query' in request.REQUEST:
                    query_arg = '?query=%s' %request.REQUEST.get('query')
                if 'page' in request.GET:
                    if query_arg:
                        query_arg = query_arg + '&'
github legios89 / django-docker-bootstrap / {{cookiecutter.repo_name}} / src / core / views.py View on Github external
def get(self, request):
        try:
            import uwsgi
            uwsgi.reload()
        except ImportError:
            pass  # Probably the django started with runserver
        return HttpResponseRedirect(reverse('rosetta-home'))
github pogorelov-ss / django-elastic-beanstalk-docker-stack / dj_app / dj_main / settings.py View on Github external
def change_code_gracefull_reload(sig):
            if autoreload.code_changed():
                uwsgi.reload()
    except Exception as error:
github cidadania / e-cidadania / src / e_cidadania / apps / rosetta / views.py View on Github external
# Try auto-reloading via the WSGI daemon mode reload mechanism
                    if  rosetta_settings.WSGI_AUTO_RELOAD and \
                        request.environ.has_key('mod_wsgi.process_group') and \
                        request.environ.get('mod_wsgi.process_group',None) and \
                        request.environ.has_key('SCRIPT_FILENAME') and \
                        int(request.environ.get('mod_wsgi.script_reloading', '0')):
                            try:
                                os.utime(request.environ.get('SCRIPT_FILENAME'), None)
                            except OSError:
                                pass
                    # Try auto-reloading via uwsgi daemon reload mechanism
                    if rosetta_settings.UWSGI_AUTO_RELOAD:
                        try:
                            import uwsgi
                            # pretty easy right?
                            uwsgi.reload()
                        except:
                            # we may not be running under uwsgi :P
                            pass
                        
                except:
                    request.session['rosetta_i18n_write'] = False
                
                request.session['rosetta_i18n_pofile']=rosetta_i18n_pofile
                
                # Retain query arguments
                query_arg = ''
                if 'query' in request.REQUEST:
                    query_arg = '?query=%s' %request.REQUEST.get('query')
                if 'page' in request.GET:
                    if query_arg:
                        query_arg = query_arg + '&'
github mediadrop / mediadrop / mediadrop / lib / base.py View on Github external
DBSession.flush()

        # Clear the settings cache unless there are multiple processes.
        # We have no way of notifying the other processes that they need
        # to clear their caches too, so we've just gotta let it play out
        # until all the caches expire.
        if not request.environ.get('wsgi.multiprocess', False):
            app_globals.settings_cache.clear()
        else:
            # uWSGI provides an automagically included module
            # that we can use to call a graceful restart of all
            # the uwsgi processes.
            # http://projects.unbit.it/uwsgi/wiki/uWSGIReload
            try:
                import uwsgi
                uwsgi.reload()
            except ImportError:
                pass
github 20tab / upy / upy / contrib / rosetta / views.py View on Github external
# Try auto-reloading via the WSGI daemon mode reload mechanism
                    if  rosetta_settings.WSGI_AUTO_RELOAD and \
                        'mod_wsgi.process_group' in request.environ and \
                        request.environ.get('mod_wsgi.process_group', None) and \
                        'SCRIPT_FILENAME' in request.environ and \
                        int(request.environ.get('mod_wsgi.script_reloading', '0')):
                            try:
                                os.utime(request.environ.get('SCRIPT_FILENAME'), None)
                            except OSError:
                                pass
                    # Try auto-reloading via uwsgi daemon reload mechanism
                    if rosetta_settings.UWSGI_AUTO_RELOAD:
                        try:
                            import uwsgi
                            # pretty easy right?
                            uwsgi.reload()
                        except:
                            # we may not be running under uwsgi :P
                            pass

                except:
                    storage.set('rosetta_i18n_write', False)
                storage.set('rosetta_i18n_pofile', rosetta_i18n_pofile)

                # Retain query arguments
                query_arg = '?_next=1'
                if 'query' in request.GET or 'query' in request.POST:
                    query_arg += '&query=%s' % request.REQUEST.get('query')
                if 'page' in request.GET:
                    query_arg += '&page=%d&_next=1' % int(request.GET.get('page'))
                return HttpResponseRedirect(reverse('rosetta-home') + iri_to_uri(query_arg))
        rosetta_i18n_lang_name = _(storage.get('rosetta_i18n_lang_name'))