zotonic command runs a number of utility commands which all operate on a Zotonic instance.
zotonic command lives in the bin/ folder of the Zotonic
source. Putting this path into your PATH variable makes working with
Zotonic a lot easier:
The command determines where the Zotonic base dir is by looking at its path; it always assumes that its zotonic basedir is one dir up from where the binary itself is.
Shell environment variables¶
See environment variables for the environment variables that can be set when using the Zotonic command line tools.
Currently, the following subcommands are implemented:
- Start the background Zotonic server instance.
- Stop the Zotonic server instance.
- Launch the Zotonic server interactively and get an EShell on the running instance. See Command-line shell.
start.shcommand in the root folder is a shortcut for this command. The Zotonic instance can be stopped with twice ctrl-C.
- Start the Zotonic server instance as a foreground process, but without the interactive EShell. This is useful when running Zotonic in a Docker container or other process.
- Restart the Zotonic server instance.
zotonic wait [timeout]
timeoutseconds (defaults to 30 seconds) for Zotonic to be started, then return.
- Get an EShell on the running Zotonic instance. See Command-line shell.
- List all sites on the running Zotonic instance and their current status.
- List all config files used for Zotonic.
- Read all config files and check if they are syntactically correct.
zotonic config [all | zotonic | erlang]
- Prints the configuration as defined in the configuration files. Taking into account all shell environment variables. Defaults to showing the zotonic config.
- Send an RPC request to the running Zotonic instance. Example: zotonic rpc “zotonic ping”
zotonic addsite [options] <site_name>
- Creates a new site with [site_name] as its name. See The addsite command for a full overview of this command.
zotonic startsite <site_name>
- Start the site with name [site_name].
zotonic stopsite <site_name>
- Stop the site with name [site_name].
zotonic restartsite <site_name>
- Restart the site with name [site_name].
zotonic sitedir <site_name>
- Get the absolute path for a site based on [site_name]
zotonic siteconfig <site_name>
- Prints the configuration of site [site_name] as defined in its configuration files.
zotonic siteconfigfiles <site_name>
- List all configuration files for of site [site_name]
zotonic dispatch <url>
Dispatch an URL. Finds the site matching the hostname and shows the dispatch information for the path. Example:bin/zotonic dispatch https://mysite.test:8443/en/page/1/foobar
zotonic dispatch <site_name> [detail]
- List all dispatch rules for a site. Add the
detailoption to show all controller options for each dispatch rule.
zotonic dispatch <site_name> <path>
Show the dispatch information for a specific path and site. Example:
bin/zotonic dispatch mysite /en/page/1/foobar
- Show the processes that consume the most CPU. Stop with twice ctrl-C.
- Show the last 50 entries of the
- Flush the caches of all sites.
zotonic flush <site_name>
- Flush the caches of the site with name [site_name].
zotonic createdb <site_name>
Create a database called zotonic_[site_name] with the basic setup in place to host a Zotonic datastore. This script will likely need to be run as postgres unless zotonic has been granted CREATEDB in postgres as follows:
ALTER ROLE zotonic WITH CREATEDB
zotonic compilefile <path/to/filename.erl>
- Compiles and reloads a single Erlang module within the Zotonic folder. This runs very fast and works very well on a save-hook of your text editor. In Emacs, it would be called like this:
(add-hook 'erlang-mode-hook '(lambda () (add-hook 'after-save-hook ' (lambda () (call-process "/path/to/your/bin/zotonic" nil "*scratch*" nil "compilefile" buffer-file-name) ) ) ))
inotify-tools to automatically recompile files when they are changed. These tools will also
enable automatic loading of changed templates, dispatch rules, and translations.
- Compiles all the Zotonic Erlang source files, modules and sites, including those in the user directory (see Global configuration).
zotonic compilebut also flushes caches and rescans all modules and sites for new templates etc.
- Reloads all (changed) beam files from disk.
- Starts Zotonic in the foreground and runs all (enunit) tests. Stops after completion of the tests.
zotonic sitetest <site_name>
- Runs all tests for the given site. Zotonic must be running. See Testing sites.