MiniServer
BoxLang includes a lightning fast web server powered by Undertow!
Last updated
BoxLang includes a lightning fast web server powered by Undertow!
Last updated
The BoxLang MiniServer runtime, a symbol of flexibility, is a lightweight and lightning-fast web server powered by Undertow. It's ideal for non-mission-critical applications, lightweight traffic, embedded web servers, and development. For those who desire a more robust server implementation, we offer our CommandBox server and CommandBox PRO with a BoxLang Subscription.
The BoxLang core, on its own, doesn't have knowledge about a web application. Our web support runtime provides this functionality, which is a crucial part of the MiniServer and the Servlet (JEE, Jakarta, CommandBox) runtime. This runtime enhances the core boxlang runtime, making it multi-runtime and web deployable.
There is no servlet container; the web server is just a simple, fast, and pure Java Undertow server. We will use the boxlang-miniserver
binary to start servers.
Once you run the command, the following output will appear in your console:
As you can see from the output, this is the result of the command:
Use the current working dir as the web root.
Bind to localhost:8080
This configures a very simple web server with some default welcome files. BoxLang will process any CFML or BoxLang extensions.
Seed the BOXLANG_HOME
to ${HOME}/.boxlang
if not set via env
ALERT: The BoxLang Core knows nothing of web or HTTP, so the form
, url
, cookie
, and cgi
scopes will only exist when running the BoxLang web server (but not in the REPL, etc).
That's practically it. This is a very lightweight server that can get the job done. You can also startup servers using our VSCode IDE by opening the command palette and clicking on startup a BoxLang web server.
Here is the collection of arguments you can pass into the binary.
Argument | Value |
---|---|
| Relative/Absolute location of the |
| Put the runtime into debug mode. By default we use |
| Bind the hostname to the mini server. By default we use |
| The port to bind the mini server to. By default we use port |
| The location of the BoxLang home for the miniserver. This is where it will look for the boxlang.json, place the log files, the compiled classes, load modules and much more. By default we use the OS home via the |
| The webserver root. By default, we use the directory from where you started the command. |
The boxlang-miniserver
binary will also scan for several environment variables as overrides to the execution process.
Env Variable | Purpose |
---|---|
| Override the |
| Enable or disable debug mode |
| Override the server HOME directory |
| Override the |
| Override the default port |
| Override the location of the web root |
| A list of Java options to pass to the startup command |
Environment variables are scanned first, then the command arguments. Thus the command arguments take precedence.
You can load up custom third-party JARs into the runtime in two manners
BOXLANG_HOME/lib
- You can place all the jars the runtime will load in this location
Remember you can use the --serverHome
to chose this.
Add via the classpath to your runner.
Please note that if you use the -cp
approach, then you need to use a full java -cp
syntax or you can customize the boxlang-miniserver
shell scripts to do your bidding.
If you want to test 3rd part libs with the web server, you’ll need to use a different syntax that uses the -cp
(classpath) JVM arg and specifies both the boxlang jar AND a semi-colon delimited list of the jars you want to use. It’s a little annoying, but this is how java works.
If you would like to use modules for the MiniServer, then you must install them using CommandBox, our Docker image or manually into the BOXLANG_HOME/modules
folder. You can ad debug
true to the arguments or env, so you can see which modules got loaded on startup.
You can use the BOXLANG_MINISERVER_OPTS
env variable to seed the Java arguments the miniserver will start with.
The runtime source code can be found here: https://github.com/ortus-boxlang/boxlang-miniserver
We welcome any pull requests, testing, docs, etc.