Module z_module_manager

Module supervisor.

Copyright © 2009-2010 Marc Worrell Date: 2009-06-03

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

Module supervisor. Uses a z_supervisor. Starts/restarts module processes.

Function Index

activate/2Activate a module.
active/1Return the list of active modules.
active/2Return whether a specific module is active.
active_dir/1Return the list of all active modules and their directories.
all/1Return the list of all modules in the database.
code_change/3Convert process state when code is changed.
deactivate/2Deactivate a module.
get_modules/1Return the list of all modules running.
get_modules_status/1Return the status of all running modules.
handle_call/3Return a list of all enabled modules managed by the z_supervisor.
handle_cast/2Sync enabled modules with loaded modules.
handle_info/2Handling all non call/cast messages.
init/1Initiates the server.
module_exists/1Check if the code of a module exists.
prio/1Return the priority of a module.
prio_sort/1Sort the results of a scan on module priority first, module name next.
scan/1Scan for a list of modules present in the site's module directories.
start_link/1Starts the module manager.
terminate/2This function is called by a gen_server when it is about to terminate.
title/1Get the title of a module.
upgrade/1Reload the list of all modules, add processes if necessary.

Function Details

activate/2

activate(Module, Context::#context{}) -> void()

Activate a module. The module is marked as active and started as a child of the module z_supervisor. The module manager can be checked later to see if the module started or not.

active/1

active(Context::#context{}) -> [atom()]

Return the list of active modules.

active/2

active(Module::atom(), Context::#context{}) -> [atom()]

Return whether a specific module is active.

active_dir/1

active_dir(Context::#context{}) -> [{atom, Dir}]

Return the list of all active modules and their directories

all/1

all(Context::#context{}) -> [atom()]

Return the list of all modules in the database.

code_change/3

code_change(OldVsn, State, Extra) -> {ok, NewState}

Convert process state when code is changed

deactivate/2

deactivate(Module, Context::#context{}) -> ok

Deactivate a module. The module is marked as deactivated and stopped when it was running.

get_modules/1

get_modules(Context) -> any()

Return the list of all modules running.

get_modules_status/1

get_modules_status(Context) -> any()

Return the status of all running modules.

handle_call/3

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 enabled modules managed by the z_supervisor

handle_cast/2

handle_cast(Message::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Sync enabled modules with loaded modules

handle_info/2

handle_info(Info, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Handling all non call/cast messages

init/1

init(Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initiates the server.

module_exists/1

module_exists(M) -> any()

Check if the code of a module exists. The database can hold module references to non-existing modules.

prio/1

prio(Module) -> integer()

Return the priority of a module. Default priority is 500, lower is higher priority. Never crash on a missing module.

prio_sort/1

prio_sort(ModuleProps::proplist()) -> proplist()

Sort the results of a scan on module priority first, module name next. The list is made up of {module, Values} tuples

scan/1

scan(Context::#context{}) -> [{atom(), dirname()}]

Scan for a list of modules present in the site's module directories. A module is always a directory, the name of the directory is the same as the name of the module.

start_link/1

start_link(SiteProps::proplist()) -> {ok, Pid} | ignore | {error, Error}

Starts the module manager

terminate/2

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/1

title(M) -> any()

Get the title of a module.

upgrade/1

upgrade(Context::#context{}) -> ok

Reload the list of all modules, add processes if necessary.


Generated by EDoc, Feb 25 2011, 21:14:41.