Roxen.git / server / base_server / configuration.pike

version» Context lines:

Roxen.git/server/base_server/configuration.pike:752:      private mapping(RoxenModule:ModuleChangedMonitor)    module_changed_monitors = ([]);      #if constant(Filesystem.Monitor.symlinks)      private class ModuleChangedMonitor   {    inherit Filesystem.Monitor.symlinks;    -  protected constant default_max_dir_check_interval = 0; -  protected constant default_file_interval_factor = 0; +  protected constant default_max_dir_check_interval = 60; +  protected constant default_file_interval_factor = 1;    protected constant default_stable_time = 0;       RoxenModule mod;       void create(RoxenModule mod)    {    ::create();    set_nonblocking(1);    this::mod = mod;    }
Roxen.git/server/base_server/configuration.pike:779: Inside #if constant(Filesystem.Monitor.symlinks)
   is_called = true;    return;    }       if (mod) {    mod = reload_module(mod->module_local_id());    }    }   }    - void module_hot_reload(RoxenModule mod) + void register_module_hot_reload(RoxenModule mod)   //! Hot-reload a module when the source file is changed, e.g. reload the module   //! automatically without having to click the Reload button in the Admin   //! Interface.   //! - //! This will only have effect if the server is started with --debug or - //! --module-debug (--once). + //! This will only have effect if the server is started with @tt{--debug@} or + //! @tt{--module-debug@} (@tt{--once@}). This can also be initalized from the + //! command line with @tt{./start --once --module-hot-reload=my-module@}, which + //! is the preferred way of enabling hot reload.   //! - //! Call this method from RoxenModule::start() like: - //! - //! @example - //! @code - //! void start() { - //! my_configuration()->module_hot_reload(this); - //! } - //! @endcode - //! +    //! @param mod   //! The module to enable hot reloading for   { - #if defined(MODULE_DEBUG) || defined(DEBUG) + #if defined(DEBUG) || defined(MODULE_DEBUG) || defined(MODULE_HOT_RELOAD)       // Already monitored    if (module_changed_monitors[mod]) {    return;    }       ModuleChangedMonitor fsw;    // Is this one of these "relying on the interpret lock"?    fsw = module_changed_monitors[mod] = ModuleChangedMonitor(mod);       string path = roxen->filename(mod);       if (!fsw->is_monitored(path)) { -  fsw->monitor(path, 1); +  report_debug(" Adding hot reload monitor for %O.\n", mod); +  fsw->monitor(path);    }      #endif // defined(...)   }    -  + void unregister_module_hot_reload(RoxenModule mod) + //! Unregister the hot reload monitor for module @[mod]. + { +  if (ModuleChangedMonitor mon = m_delete(module_changed_monitors, mod)) { +  report_debug("Removing hot reload monitor for %O.\n", mod); +  mon->clear(); +  destruct(mon); +  } + } +    #else /* Filesystem.Monitor.symlinks */      //! @ignore   private class ModuleChangedMonitor {} - void module_hot_reload(RoxenModule mod){} + void register_module_hot_reload(RoxenModule mod){} + void unregister_module_hot_reload(RoxenModule mod){}   //! @endignore      #endif /* !Filesystem.Monitor.symlinks */         private void safe_stop_module (RoxenModule mod, string desc)   {    if (mixed err = catch (mod && mod->stop &&    call_module_func_with_cbs (mod, "stop", 0)))    report_error ("While stopping " + desc + ": " + describe_backtrace (err));    -  if (ModuleChangedMonitor mon = m_delete(module_changed_monitors, mod)) { -  mon->clear(); -  destruct(mon); +  unregister_module_hot_reload(mod);   } - } +       private Thread.Mutex stop_all_modules_mutex = Thread.Mutex();      private void do_stop_all_modules (Thread.MutexKey stop_lock)   {    foreach(sorted_modules, RoxenModule m) {    safe_stop_module(m, "module");    }       end_logger();
Roxen.git/server/base_server/configuration.pike:4866:    report_error(LOC_M(45, "Failed to enable the module %s. Skipping.")    +"\n%s\n", tmp_string, describe_backtrace(err));    got_no_delayed_load = -1;    }    }    enable_module_batch_msgs = 0;   // roxenloader.pop_compile_error_handler();    forcibly_added = ([]);    }    -  foreach( ({this_object()})+indices( otomod ), RoxenModule mod ) -  if( mod->ready_to_receive_requests ) + #ifdef MODULE_HOT_RELOAD +  array(string) hot_mods = roxen->query_hot_reload_modules(); +  array(string) hot_confs = roxen->query_hot_reload_modules_conf(); + #endif +  +  foreach( ({this_object()})+indices( otomod ), RoxenModule mod ) { +  if( mod->ready_to_receive_requests ) {    if( mixed q = catch( mod->ready_to_receive_requests( this_object() ) ) ) {    report_error( "While calling ready_to_receive_requests in "+    otomod[mod]+":\n"+    describe_backtrace( q ) );    got_no_delayed_load = -1;    } -  +  }    -  + #ifdef MODULE_HOT_RELOAD +  if (has_index(mod, "is_module") && +  (!hot_confs || has_value(hot_confs, name))) +  { +  sscanf (mod->module_local_id(), "%s#", string mod_name); +  +  if (has_value(hot_mods, mod_name)) { +  register_module_hot_reload(mod); +  } +  } + #endif +  } +     foreach( after_init_hooks, function q )    if( mixed w = catch( q(this_object()) ) ) {    report_error( "While calling after_init_hook %O:\n%s",    q, describe_backtrace( w ) );    got_no_delayed_load = -1;    }       after_init_hooks = ({});       inited = 1;