z_sites_manager (zotonic_core v1.0.0-rc.17)
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.
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.
Set extra configurations for a site. Will overlay the read configuration when the site is started.
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 all sites
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.
Let the sites manager reload the configuration of a site.
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.
Types
Functions
-spec await_startup(z:context() | atom()) -> ok | {error, bad_name | failed | removing | stopped | stopping}.
Wait for a site to complete its startup sequence.
Convert process state when code is changed
-spec do_scan_sites() -> #{Site :: atom() => proplists:proplist()}.
Scan all sites subdirectories for the site configurations.
-spec filechanged_observer(#zotonic_filehandler_filechange{verb :: modify | create | delete, file :: binary(), basename :: binary(), extension :: binary()}, 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.
Do something for all sites that are currently running.
-spec get_builtin_sites() -> [atom()].
The list of builtin sites, they are located in the zotonic/apps/ directory.
-spec get_fallback_site() -> atom() | undefined.
Return the name of the site to handle unknown Host requests
Fetch the configuration of a specific site.
-spec get_site_config_overrides(Site) -> List when Site :: atom(), List :: proplists:proplist().
Set extra configurations for a site. Will overlay the read configuration when the site is started.
-spec get_site_contexts() -> [z:context()].
Return a list of contexts for all running sites.
-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.
-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
Return all sites
-spec info() -> {ok, #{atom() => #site_status{site :: atom(), is_enabled :: term(), status :: site_status(), pid :: undefined | pid(), start_time :: undefined | z_datetime:timestamp(), stop_time :: undefined | erlang:timestamp(), stop_count :: integer(), crash_time :: undefined | erlang:timestamp(), crash_count :: integer(), config :: list()}}}.
Return information on all running sites.
Initiates the server.
-spec is_sites_running() -> boolean().
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.
-spec put_site_config_overrides(Site, Overrides) -> ok when Site :: atom(), Overrides :: proplists:proplist().
Override a given site config with arbitrary key/value pairs. Should be called before the site is started.
Let the sites manager reload the configuration of a site.
Restart a site or multiple sites.
-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.
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.
Wait for a site to be running, max 30 secs.