Skip to content

Version 6.2.1

Latest
Compare
Choose a tag to compare
@jo-tools jo-tools released this 16 Mar 17:13
· 5 commits to main since this release
afc9fc8

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:

  1. Launch Argument
  2. 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

Demos

The provided Demos have been updated to respect Launch Arguments and Environment Variables.
In DebugBuilds 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:

  1. Launch Argument: --Demo=1
  2. Environment Variable: EXPRESS_DEMO=1
  3. 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
  • 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

ScreenShot:
Express_6-2-1