Hi Guys,
I would like to solicit on how do you do things, like:
It’s been obvious that to update XOJO web app, it need to kill the app and reupload a bunch of files and re-run again. However, what if you found some bug and you need to update your web app asap while there is a hundred users connected to it.
How do you handle this type of situation?
You simply cannot update the app while it runs.
But, do you really have hundreds of visitors 24 hours a day ?
With a cgi app, you can set autoquit to true, so when all sessions are closed, the app quits.
Here is the code created by Phillip Zedalis of 1701 Software I have in my apps Open event handler :
if not DebugBuild then
timerShutDown = New Timer
AddHandler timerShutDown.Action, AddressOf timerShutDown_Action
timerShutDown.Period = 10000
timerShutDown.Mode = Timer.ModeMultiple
end if
TimerShutDown is a Timer property of app
Here is the content of the timerShutDown_Action method that handles the Action event of the timer:
[code]Public Sub timerShutdown_Action(sender As Timer)
dim f as FolderItem
f = getFolderItem("")
if not DebugBuild then
f = getFolderItem(f.NativePath + Lowercase(App.ExecutableFile.Name)+".cgi", Folderitem.PathTypeNative)
else
f = getFolderItem(“My Application.debug”, Folderitem.PathTypeNative)
end if
if (f.Exists() = False) or App.SessionCount = 0 then
App.Quit()
end if
End Sub
[/code]
If the .cgi file is removed from the server, the app quits. You can upload a new version, so next time a visitor comes up, he gets the updated app.
Probably you could use a loadbalancer (for example one of the capabilities of nginx) to solve this problem.
Look here for a starter on how to build a load balancer. Kudos to Christian for posting this.
Thanks @Maximilian Tyrtania for pointing to my own blog.
That’s a very simple system we have working with a few client projects.
Easy and reliable.
Can work with 4 well, but also with 10 instances.
If you’re using Xojocloud you can request a load balancer to be created. You then point your domain name to the load balancer and it will route to your online servers. That way you can take them down one at a time and update them. We currently have groups of two ui servers and a database server behind a load balancer. It has worked well for our web application.