mix beacon.gen.site (Beacon v0.5.0)
View SourceGenerates a new Beacon site in the current project.
Remember to execute mix beacon.install
first if this is the first site you're generating in your project and you have not installed Beacon yet.
Examples
mix beacon.gen.site --site my_site
mix beacon.gen.site --site my_site --path / --host mysite.com
To define a custom host to work locally and the production host:
mix beacon.gen.site --site my_site --path / --host-dev local.mysite.com --host mysite.com
Using --host-dev for Multiple Sites
The --host-dev
option is particularly useful when you need to run multiple sites at the root path (/
). Without custom hosts, all sites would try to serve at localhost:4000/
, which would cause conflicts.
For example, if you have two sites:
mix beacon.gen.site --site blog --path / --host-dev local.blog.mysite.com --host blog.mysite.com
mix beacon.gen.site --site shop --path / --host-dev local.shop.mysite.com --host shop.mysite.com
To make this work locally, you have two options:
Edit your
/etc/hosts
file (or equivalent) to add:127.0.0.1 local.blog.mysite.com 127.0.0.1 local.shop.mysite.com
This is the simplest solution and works well for local development. Locally in the dev environment, sites would be accessible at:
http://local.blog.mysite.com:4000/
http://local.shop.mysite.com:4000/
Use a local development tunneling service. Some options:
Options
--site
(required) - The name of your site. Should not contain special characters nor start with "beacon_"--path
(optional) - Where your site will be mounted. Follows the same convention as Phoenix route prefixes. Defaults to"/"
--host
(optional) - If provided, site will be served on that host for production environments.--host-dev
(optional) - If provided, site will be served on that host for dev (local) environments.--port
(optional) - The port to use for http requests. Only needed when--host
is provided. If no port is given, one will be chosen at random.--secure-port
(optional) - The port to use for https requests. Only needed when--host
is provided. If no port is given, one will be chosen at random.--endpoint
(optional) - The name of the Endpoint Module for your site. If not provided, a default will be generated based on thesite
. For example,beacon.gen.site --site my_site
will useMySiteEndpoint
--secret-key-base
(optional) - The value to use for secret_key_base in your app config. By default, Beacon will generate a new value and update all existing config to match that value. If you don't want this behavior, copy the secret_key_base from your app config and provide it here.--signing-salt
(optional) - The value to use for signing_salt in your app config. By default, Beacon will generate a new value and update all existing config to match that value. But in order to avoid connection errors for existing clients, it's recommened to copy thesigning_salt
from your app config and provide it here.--session-key
(optional) - The value to use for key in the session config. Defaults to"_your_app_name_key"
--session-same-site
(optional) - Set the cookie session SameSite attributes. Defaults to "Lax"