z_sites_manager (zotonic_core v1.0.0-rc.14)

Server managing all sites running inside Zotonic. Starts the sites according to the config files in the sites subdirectories. Handles scanning of all site directories for config files.

Link to this section Summary

Functions

Wait for a site to complete its startup sequence.
Convert process state when code is changed
Scan all sites subdirectories for the site configurations.
Called by the zotonic_filehandler after a file has been changed. This relays the file change event to all sites using the #filewatcher{} event.
Do something for all sites that are currently running.
The list of builtin sites, they are located in the zotonic/apps/ directory.
Return the name of the site to handle unknown Host requests
Fetch the configuration of a specific site.
Return a list of contexts for all running sites.
Get the status of a particular site
Return a list of all sites and their current running status. This is coming from the ets table, so might be a bit delayed.
Return a list of all sites, their current running status and their hosts configs
Return information on all running sites.
Initiates the server.
Return true iff all sites are running. Don't count sites manually stopped.
Tell the sites manager that a module was loaded, check changes to observers, schema.
Override a given site config with arbitrary key/value pairs. Should be called before the site is started.
Restart a site or multiple sites.
Set the status of a site, called by the site supervisor
Start a site or multiple sites.
Starts the server
Stop a site or multiple sites.
This function is called by a gen_server when it is about to terminate.
Sync the supervised sites with the sites in the sites directory. Removes and stops deleted sites, adds (but does not start) new sites.
Wait for a site to be running, max 30 secs.

Link to this section Types

Link to this type

site_status/0

-type site_status() :: new | starting | running | stopping | retrying | failed | stopped | removing.

Link to this section Functions

Link to this function

await_startup(Context)

-spec await_startup(z:context() | atom()) ->
                 ok | {error, bad_name | failed | removing | stopped | stopping}.
Wait for a site to complete its startup sequence.
Link to this function

code_change(OldVsn, State, Extra)

Convert process state when code is changed
Link to this function

do_scan_sites()

-spec do_scan_sites() -> #{Site :: atom() => proplists:proplist()}.
Scan all sites subdirectories for the site configurations.
Link to this function

do_scan_sites(_)

Link to this function

filechanged_observer(Zotonic_filehandler_filechange, CallContext)

-spec filechanged_observer(#zotonic_filehandler_filechange{}, term()) -> ok.
Called by the zotonic_filehandler after a file has been changed. This relays the file change event to all sites using the #filewatcher{} event.
-spec foreach(fun((z:context()) -> any())) -> ok.
Do something for all sites that are currently running.
Link to this function

get_builtin_sites()

-spec get_builtin_sites() -> [atom()].
The list of builtin sites, they are located in the zotonic/apps/ directory.
Link to this function

get_fallback_site()

-spec get_fallback_site() -> atom() | undefined.
Return the name of the site to handle unknown Host requests
Link to this function

get_site_config(Site)

-spec get_site_config(atom()) -> {ok, list()} | {error, bad_name | term()}.
Fetch the configuration of a specific site.
Link to this function

get_site_config_overrides(Site)

Link to this function

get_site_contexts()

-spec get_site_contexts() -> [z:context()].
Return a list of contexts for all running sites.
Link to this function

get_site_status(Context)

-spec get_site_status(z:context() | atom()) -> {ok, site_status()} | {error, bad_name}.
Get the status of a particular site
-spec get_sites() -> #{atom() => site_status()}.
Return a list of all sites and their current running status. This is coming from the ets table, so might be a bit delayed.
Link to this function

get_sites_hosts()

-spec get_sites_hosts() ->
                   {ok, #{atom() => {site_status(), [{Host :: binary(), Prio :: pos_integer()}]}}}.
Return a list of all sites, their current running status and their hosts configs
Link to this function

handle_call(Message, From, State)

Return all sites
Link to this function

handle_cast(Message, State)

Link to this function

handle_info(Info, State)

-spec info() -> {ok, #{atom() => #site_status{}}}.
Return information on all running sites.
Initiates the server.
Link to this function

is_sites_running()

-spec is_sites_running() -> boolean().
Return true iff all sites are running. Don't count sites manually stopped.
Link to this function

module_loaded(Module)

Tell the sites manager that a module was loaded, check changes to observers, schema.
Link to this function

put_site_config_overrides(Site, Overrides)

Override a given site config with arbitrary key/value pairs. Should be called before the site is started.
Restart a site or multiple sites.
Link to this function

set_site_status(Site, Status)

-spec set_site_status(atom(), site_status()) -> ok.
Set the status of a site, called by the site supervisor
Start a site or multiple sites.
Starts the server
Stop a site or multiple sites.
Link to this function

terminate(Reason, State)

This function is called by a gen_server when it is about to terminate.
-spec upgrade() -> ok.
Sync the supervised sites with the sites in the sites directory. Removes and stops deleted sites, adds (but does not start) new sites.
Link to this function

wait_for_running(Site)

-spec wait_for_running(atom()) -> ok | {error, bad_name | timeout | stopped | removing | term()}.
Wait for a site to be running, max 30 secs.
Link to this function

wait_for_running(Site, Secs)

-spec wait_for_running(atom(), Secs :: integer()) ->
                    ok | {error, bad_name | timeout | stopped | removing | term()}.