Lifeboat: Will it work with Express instead of a Xojo Web App

@Tim_Parnell

I’ve never built a Xojo Web App but I understand that your amazing Lifeboat tool makes managing one on your own VPS a doddle.

I’m building a static website to showcase my retro collection. I have a SQLite database containing details about what’s in my collection. I want to build a simple REST API to that database that my site can query with JavaScript to show a few facts (e.g. latest thing added, total in collection, etc).

It seems like total overkill to build a full web app to do this so I was thinking about using the lightweight Express HTML server (used to be Aloe Express). This can be run as a console app. Would lifeboat be able to manage this (since it’s just a demon console app - see the demo) or am I best off making a bloated web app without a GUI just to host a REST API?

You could use PHP, or as I know you’ve dabbled with Swift, there’s also the Swift on Server project… But before you go down these routes, I’d recommend awaiting Tim’s response.

At some point, I’m going to have to replace my ancient Xojo Web 1.0 app and so I’m interested in this too. My app is also used as an API, therefore a GUI isn’t needed.

1 Like

I don’t know about API 2 and I’m no web app expert, but I think an API 1 non-GUI web app to do what you’re proposing would be fairly trivial and not so bloated. I recently wrote one to buffer slow S3 bucket listings and it’s got like 30 lines of code in HandleURL and a couple of small methods. Only took a few hours to get working and deployed.

1 Like

Without testing I can only say that, if this doesn’t work right now, I’m sure Tim can add support to it.

2 Likes

Personally, I’d just use a Xojo Web app and return true in the HandleURL event to prevent Sessions from ever starting. This keeps me rolling with tools I’m familiar with.

If you wanted to use PHP, Lifeboat can certainly help you out there.

I took a quick peek at Express, and since it takes the same launch arguments as a Web App you might actually be able to use Lifeboat to deploy. The demo app won’t work because it waits for input to launch a demo, so you will need to configure the server app to behave the same as a Xojo Web app: Launch right into server mode.

Alberto’s right, if we need to make small changes to get it working I would be interested to know. Give it a try and let me know your results.

6 Likes

Thanks for the hints Tim. I’ll see if I can spin something up using Express firstly (since I don’t really want to commit to a Xojo web license). If that’s no good then I’ll do as you suggest with a Xojo web app.

1 Like

I’ve replaced App.Open with this line of code in Express-Demo-Console.xojo_project of Express.

Me.Demo_01_HelloWorld(args)

Deployed with Lifeboat - and it worked out of the box.

That I have tried with the Demo of Lifeboat… so I can’t say if it works with multiple instances of an Express App, or with multiple different Express apps - the Lifeboat Demo doesn’t allow me to try that :wink:

It looks good to me at a first quick glance.

If @Tim_Parnell lets us know which launch arguments Lifeboat uses/needs for a (web) app to be supported, we should/could add/modify Express with those, so that this duo is working together nicely.

5 Likes

Lifeboat makes use of the --Port= parameter to control the web app instances and --UploadPath= if the user chooses to flip that switch. --UploadPath= just controls a custom temporary directory the Web framework uses, I don’t think that’s implemented in Express.

I am pleased to hear of your success! I will reach out with a testing key so that you may test load balancing and multiple apps (if you wish).

3 Likes

You’re always welcome - and thanks for the testing key :hearts:

Correct. If someone wanted to use this parameter (e.g. in own code that processes a request, if a temp path is needed for some purpose), then it’s as easy as that to get the passed-in value:

Var arguments As Dictionary = Express.ArgsToDictionary(args)
If arguments.HasKey("--UploadPath") Then
  // do something with it
End If

As for now I’ve just tried quickly. And since the --Port= parameter is exactly the same in Express such as in Xojo Web, this works just fine.

Regarding Load Balancing I noticed immediately that LifeBoat configures (by default? only?) the Load Balancing Method ip_hash. So all connections from the same IP go to the same instance. Connecting from different IP’s revealed that different instances are being used - so again: working just fine and “out of the box” with Lifeboat & Express.

It probably makes sense for Xojo Web applications to have that Load Balancing Method. Just thinking of WebApps that are using Sessions - so all requests from the same “user” should go to the same instance.

For other usages (e.g. a simple WebService; be that with Express or with Xojo Web) other Load Balancing Methods (Round-Robin | Least-Connected) would make more sense.

Anyway - this will quickly get off-topic.
I have a couple of ideas for both Express and Lifeboat which would be good to have, to make them work together even better. I’ll let you know.

Let’s stop this post with: “Yes, Lifeboat and Express work together just fine”.

1 Like

I just want to touch on the load balancing directive, because that does seem on topic for both Lifeboat and Express.

The load balancing method ip_hash is the only one that is compatible with a Session based web app. If you are running a REST API and are denying sessions you can change the directive with the hidden-by-default advanced options. In an effort to make Lifeboat simple for new users, this tab needs to be enabled in Preferences first.

2 Likes