lexer serve
The one command that runs things, and its flags: --port, --watch, --background, --production.
lexer serve <file> [--port N] [--watch] [--background]
[--production] [--log <file>]Reads the file, parses it and runs it. There is no build and no run — serve already does both.
Flags may come before or after the filename:
lexer serve app.lexer --port 8080The exit code is 0 on success and 1 on failure.
Flags#
| Flag | Effect |
|---|---|
--port N | the CLI port; overrides the port set inside the application |
--watch | restarts the application whenever the file changes |
--background | starts a separate process and writes output to .logs/YYYYMMDD.log |
--production | production mode; out.log becomes the default when --log is absent |
--log <file> | redirects output to a file; does not change the mode |
--port and --production answer different questions: one is where to listen, the other is how much the error page says.
Development#
lexer serve app.lexer --watchEvery time you save the file the server shuts down gracefully and comes back up. Refreshing the browser is enough.
--watch follows not only the entry file but the .lx files it imports; changing a file under lib/ restarts it too.
In the background#
lexer serve app.lexer --background --port 8080The process detaches from the terminal. out() output and [lexer]-prefixed diagnostics go to .logs/YYYYMMDD.log in the application directory.
foreground → terminal
background → <application directory>/.logs/YYYYMMDD.logThe filename carries the date as YYYYMMDD rather than DDMMYY so that chronological order and filesystem order are the same thing.
Run mode#
lexer serve app.lexer # development (default)
lexer serve app.lexer --production # production
LEXER_ENV=production lexer serve app.lexer # productionThe CLI wins: when --production is given, the environment variable is not consulted.
The mode only changes the error page:
development: sayfa calistirilamadi: /path/app.lexer:25:19: tanimsiz degisken: $yok
production: sayfa calistirilamadi (olay: 4b17df5d3b21)The detail is written to the log file under the same id. You find the logged line from the code the user reports, and no file path or line number leaks to the browser.
Reading the mode from the language#
use modes
if mode == modes.development then
out("development mode")
end if| Name | What it is | Needs use |
|---|---|---|
mode | the value itself | no |
modes.development · modes.production | constants | yes |
modes.current | the same as mode | yes |
modes.is_production() · modes.is_development() | shorthand | yes |
mode and modes are deliberately separate: one is a value, the other a set.
The application cannot change the mode. If it could, the answer to "which mode are we in" could change midway through a run.
Port#
The port can come from three places, in this order of precedence:
lexer serve app.lexer --port 8080 # 1. CLI flag$app.listen({port: 3000}) # 2. listen argument
$app = new http_server({port: 3000}) # 3. object settingNext#
Process management — status, logs, stop.