Settings and ports
Perch's environment variables, its port, and how to put it behind a password.
Perch listens on 127.0.0.1:4100 with no login by default.
Environment variables
| Variable | Default | What it does |
|---|---|---|
CARDINAL_WORKSPACE | required | The workspace folder |
CARDINAL_DATABASE_URL | required | The workspace's database, ecto://USER:PASS@HOST:PORT/DB. Perch's connection is read-only |
PERCH_PORT | 4100 | The port. cardinal start --verbose and cardinal perch pass it through |
PERCH_BIND | 127.0.0.1 | The address. Any other address needs PERCH_PASSWORD_HASH, or Perch stops at boot and says why |
PERCH_PASSWORD_HASH | unset | An Argon2 hash. Turns on a login page and a session cookie for every page |
SECRET_KEY_BASE | made at boot in dev | Signs cookies. In dev, which bin/perch runs by default, a key made at boot means a restart signs everyone out. Required in prod |
CARDINAL_HOME | from the workspace's mix.exs | The Cardinal checkout, used to find bin/cardinal and the load scripts |
The Frappe migrator also defaults to port 4100. Set PERCH_PORT to another port if both run on one machine.
Reach Perch from another machine
Hash a password:
mix perch.hash 'a long password' # prints $argon2id$v=19$...Start Perch with the hash and an address. Single quotes keep the hash's $ signs.
PERCH_PASSWORD_HASH='$argon2id$v=19$...' PERCH_BIND=0.0.0.0 bin/perchFive failed logins from one address in a minute block that address for the rest of the minute. The sixth attempt is refused before the hash check.