Skip to content

Change an app while it runs

matterdata dev serves one application on your computer. It watches the application directory. When you save a file, it compiles the application and applies the change to the running tenant. You do not stop the server and you do not install again.

Give the command the application directory:

Terminal window
matterdata dev dsl/examples/expenses

If the tenant does not exist, dev creates it from the application and loads the files of seed/. It prints the address and a login that holds every role of the application:

dev tenant "expenses" at http://expenses.localhost:8080/
sign in as dev@expenses.example password dev-password (dept_head, employee, finance)

Use a browser on the same computer. *.localhost always points to your computer.

Flag Effect
-tenant <name> The tenant name. The default is the name of the directory.
-dir <dir> The directory of the tenant file. The default is .matterdata-dev. Keep it outside the application directory.
-addr <host:port> The address. The default is 127.0.0.1:8080. dev accepts only a loopback address.
-login <email>:<password>[:<roles>] A login of a new tenant. Repeat the flag for more logins. The first login is the tenant administrator. A login with no roles holds every role of the application.
-reset Delete the tenant and create it again from the application. The data is lost.

dev runs like serve -dev: the cookies have no Secure flag, and dev() is true. See Show a page only in development.

dev checks the .mtd files, the .ts hook modules and seed/*.csv every 500 ms. It waits 200 ms after the last change, then it:

  1. compiles the application and prints each error as file:line:column;
  2. runs the whole migration on a copy of the tenant file and deletes the copy;
  3. applies the change, and prints one line.
dev: deployed expenses: 1 step (add_column claims.note), model v1 -> v2; window 12 ms; digest 47afc2f085068aff

A change is served within two seconds of the save. The window is the time that a request waited, in milliseconds.

When the application has a tsconfig.json, a tsc is found, and .matterdata/sdk.d.ts exists, dev also runs the type check of the hooks in the background after each save. It does not wait for it. The errors appear later as warnings, and they never block a deploy. When the check cannot run, dev says why once. See Write a hook in TypeScript with types. dev also brings an existing .matterdata/sdk.d.ts up to date with the schema, and never creates it.

If the application does not compile, dev deploys nothing. The tenant keeps the last good version. Fix the file and save again.

dev does not delete data and does not leave a new column empty on rows that exist, unless you allow it. It prints the refusal, and the refusal names the flag:

dev: refused; nothing was applied and expenses keeps serving its last model:
- drop_column expenses.claims.note destroys data … Pass -allow-destructive expenses.claims.note …

Do one of these:

  • Stop dev and start it again with the flag, for example -allow-destructive expenses.claims.note. The other flags are -allow-policy and -accept-null. They have the same meaning as for matterdata upgrade.
  • Start dev with -reset.
  • A changed file in seed/ is checked and not loaded, because the tenant already holds rows. Use -reset to load it.
  • dev shows the errors in the terminal only. The browser does not show them.
  • dev is not for a tenant with data that you need. To change an application on a server that is serving, use matterdata deploy. To move a stopped node to a new engine version, use matterdata upgrade.

Website privacy policy