Copyright © 2009-2020 Marc Worrell
Behaviours: gen_server.
Authors: Marc Worrell (marc@worrell.nl).
manage_schema() = install | {upgrade, integer()}
module_status() = new | starting | running | stopping | restarting | retrying | failed | stopped | removing
activate/2 | Activate a module. |
activate_await/2 | |
activate_precheck/2 | Before activating a module, check if it depends on non-activated other modules. |
active/1 | Return the list of active modules. |
active/2 | Return whether a specific module is active. |
active_dir/1 | Return the list of all active modules and their directories. |
all/1 | Return the list of all modules in the database. |
code_change/3 | Convert process state when code is changed. |
deactivate/2 | Deactivate a module. |
deactivate_precheck/2 | Before deactivating a module, check if active modules depend on the deactivated module. |
dependencies/1 | Return a module's dependencies as a tuple usable for z_toposort:sort/1. |
dependency_sort/1 | Sort all modules on their dependencies (with sub sort the module's priority). |
get_depending/0 | Return a table with per dependeny which modules depend on it. |
get_modules/1 | Return the list of all modules running. |
get_modules_status/1 | Return the status of all running modules. |
get_provided/0 | Return a table with per provision which modules provide it. |
get_provided/1 | Return the list of all provided functionalities in running modules. |
get_upgrade_status/1 | Return the status of any ongoing upgrade. |
handle_call/3 | Return a list of all modules. |
handle_cast/2 | Sync enabled modules with loaded modules. |
handle_info/2 | |
init/1 | Initiates the server. |
is_provided/2 | Check if a service is provided by any module. |
lib_dir/1 | |
module_exists/1 | Check if the code of a module exists. |
module_reloaded/2 | Check all observers of a module, ensure that they are all active. |
module_to_app/1 | |
prio/1 | Return the priority of a module. |
prio_sort/1 | Sort the results of a scan on module priority first, module name next. |
reinstall/2 | Reinstall the given module's schema, calling Module:manage_schema(install, Context); if that function exists. |
restart/2 | Restart a module, activates the module if it was not activated. |
scan/0 | Scan for a list of modules. |
start_link/1 | Starts the module manager. |
startable/2 | |
terminate/2 | This function is called by a gen_server when it is about to terminate. |
title/1 | Get the title of a module. |
upgrade/1 | Reload the list of all modules, add processes if necessary. |
upgrade_await/1 | Wait till all modules are started, used when starting up a new or test site. |
whereis/2 | Return the pid of a running module. |
activate(Module::atom(), Context::z:context()) -> ok | {error, not_found}
Activate a module. The module is marked as active and started as a child of the module supervisor. The module manager can be checked later to see if the module started or not.
activate_await(Module::atom(), Context::z:context()) -> ok | {error, not_active | not_found}
activate_precheck(Module::atom() | [atom()], Context::z:context()) -> ok | {error, #{atom() => [atom()]}} | {error, {cyclic, z_toposort:cycles()}}
Before activating a module, check if it depends on non-activated other modules. This checks the complete graph of all modules that are currently activated plus the new modules. All missing dependencies will be listed. This also shows the modules that have missing dependencies and can't run because of those missing dependencies.
active(Context::#context{}) -> [Module::atom()]
Return the list of active modules.
active(Module::atom(), Context::#context{}) -> boolean()
Return whether a specific module is active.
active_dir(Context::z:context()) -> [{Module::atom(), Dir::file:filename_all()}]
Return the list of all active modules and their directories
all(Context::z:context()) -> [atom()]
Return the list of all modules in the database.
code_change(OldVsn, State, Extra) -> {ok, NewState}
Convert process state when code is changed
deactivate(Module::atom(), Context::z:context()) -> ok
Deactivate a module. The module is marked as deactivated and stopped when it was running.
deactivate_precheck(Module::atom(), Context::z:context()) -> ok | {error, #{atom() => [atom()]}} | {error, {cyclic, z_toposort:cycles()}}
Before deactivating a module, check if active modules depend on the deactivated module. This checks the complete graph of all modules that are currently activated minus the deactivated module. All missing dependencies will be listed. This also shows the modules that have missing dependencies and can't run because of those missing dependencies.
dependencies(M::{atom(), term()} | atom()) -> {atom() | {atom(), term()}, Depends::[atom()], Provides::[atom()]}
Return a module's dependencies as a tuple usable for z_toposort:sort/1.
dependency_sort(Context::z:context() | [atom()]) -> {ok, [atom()]} | {error, {cyclic, z_toposort:cycles()}}
Sort all modules on their dependencies (with sub sort the module's priority)
get_depending() -> #{atom() := [atom()]}
Return a table with per dependeny which modules depend on it.
get_modules(Context) -> any()
Return the list of all modules running.
get_modules_status(Context) -> any()
Return the status of all running modules.
get_provided() -> #{atom() := [atom()]}
Return a table with per provision which modules provide it.
get_provided(Context::z:context()) -> [atom()]
Return the list of all provided functionalities in running modules.
get_upgrade_status(Context) -> any()
Return the status of any ongoing upgrade
handle_call(Message::Request, From, State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}
Return a list of all modules
handle_cast(Message::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
Sync enabled modules with loaded modules
handle_info(Info, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
init(Site::Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}
Initiates the server.
is_provided(Service::atom(), Context::z:context()) -> boolean()
Check if a service is provided by any module.
lib_dir(Module::atom()) -> {error, bad_name} | file:filename()
module_exists(M) -> any()
Check if the code of a module exists. The database can hold module references to non-existing modules.
module_reloaded(Module::atom(), Context::#context{}) -> ok
Check all observers of a module, ensure that they are all active. Used after a module has been reloaded
module_to_app(Module::atom()) -> atom()
prio(Module::atom()) -> integer()
Return the priority of a module. Default priority is 500, lower is higher priority. Never crash on a missing module.
prio_sort(ModuleProps::[atom() | {atom(), term()}]) -> [atom() | {atom(), term()}]
Sort the results of a scan on module priority first, module name next. The list is made up of {module, Values} tuples
reinstall(Module, Context) -> any()
Reinstall the given module's schema, calling Module:manage_schema(install, Context); if that function exists.
restart(Module::atom(), Context::#context{}) -> ok | {error, not_found}
Restart a module, activates the module if it was not activated.
scan() -> [{Module::atom(), Application::atom(), Dir::file:filename_all()}]
Scan for a list of modules. A module is always an OTP application, the name of the application is similar to the name of the module.
start_link(SiteProps::proplist()) -> {ok, Pid} | ignore | {error, Error}
Starts the module manager
startable(M, Context) -> any()
terminate(Reason, State) -> void()
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.
title(M) -> any()
Get the title of a module.
upgrade(Context::z:context()) -> ok
Reload the list of all modules, add processes if necessary.
upgrade_await(Context::z:context()) -> ok | {error, timeout}
Wait till all modules are started, used when starting up a new or test site.
whereis(Module::atom(), Context::z:context()) -> {ok, pid()} | {error, not_running | not_found}
Return the pid of a running module
Generated by EDoc