If you are going to deploy a service using Express to a WebServer with LifeBoat or run it in a Docker Container, then you want to configure Express Settings depending on your needs.
You could always launch the service application with arguments:
--Port=xxx
--MaxSockets=xxx
--MinSockets=xxx
--Loopback
(use Loopback Network Interface)--Nothreads
(disable MultiThreading)--Secure
(use SSL)--ConnectionType=xxx
(Xojo SSL Socket Connection Type)--CertificateFile=xxx
--CertificatePassword
--CloseConnections
(disable Keep-Alive)--SilentStart
In Docker Environments you might want a Container running an Express Instance in various environments (Production, Development). So different Log Verbosity or different Ports or other Settings are required in each environment.
Environment Variables
Creating an Express Server Instance:
Server = New Express.Server(args, AddressOf DemoHelloWorld.RequestProcess)
This will pick up both Launch Arguments and Environment Variables in the following priority:
- Launch Argument
- Environment Variable
The following Environment Variables are respected:
EXPRESS_PORT=xxx
EXPRESS_MAXSOCKETS=xxx
EXPRESS_MINSOCKETS=xxx
EXPRESS_LOOPBACK=true
EXPRESS_NOTHREADS=true
EXPRESS_CLOSECONNECTIONS=true
EXPRESS_SILENTSTART=true
Note: you need to specify the value true
for the last four Environment Variables.
The SSL related launch arguments have not been implemented.
In hosted environments you could/should use a Gateway (e.g. nginx) in front to handle SSL (and certificate renewals) and Load Balancing.
Demo 1: Hello World
This Demo has been updated to display Express Server Infos.
Express | Lifeboat
This ScreenShot shows how Environment Variables have been configured in LifeBoat.
The deployed Express instance picks them up:
![Express_6-2-0](https://private-user-images.githubusercontent.com/11751753/313350756-8854b745-235b-4491-9a8e-49692355d75a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwOTI1MTYsIm5iZiI6MTcyNDA5MjIxNiwicGF0aCI6Ii8xMTc1MTc1My8zMTMzNTA3NTYtODg1NGI3NDUtMjM1Yi00NDkxLTlhOGUtNDk2OTIzNTVkNzVhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDE4MzAxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjNGY5YzE4NTUzNmM5OTA0NDk5OTk3Njk3ODVmYzU1ODI1OGY5Y2MyMzAwMThjNzUxMThjMWZmZGRkMDI0NGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8-L85rQ0i4U9oheQCW2plvks5jMu-Gg5i4nrJULeCYI)
Demos
The provided Demos have been updated to respect Launch Arguments and Environment Variables.
In DebugBuild
s the Loopback Network Interface (localhost
, 127.0.0.1
) is being used by default.
Express-Demo-Console
Now uses a demo in the following priority:
- Launch Argument:
--Demo=1
- Environment Variable:
EXPRESS_DEMO=1
- if no set: displays a choice and asks which demo to use
This now allows to
- Build the Express-Demo-Console.xojo_project without modifying any code
- Deploy to a webserver (e.g. using Lifeboat)
- Set Environment Variable
EXPRESS_DEMO=1
- Stage - and enjoy/test the Demo 1
- Set Environment Variable
EXPRESS_DEMO=2
- Stage - and enjoy/test the Demo 2
- Set Environment Variable
- Deploy to a webserver manually
- Launch with Arguments
--Port=xxxx --Demo=1
(or set the Environment Variables) - Enjoy/test the Demo 1
- Launch with Arguments
--Port=xxxx --Demo=2
(or set the Environment Variables) - Enjoy/test the Demo 2
- Launch with Arguments