I was wandering how others implement a maintenance page, while you’re working on the main web app.
my big web app has now a small number of users, but it seems it will grow up soon.
for now, i simply quit the web app at hours where nobody is supposed to use it
I would like to hears what would be better practice
make a small web app only displaying “maintenance time” that I run when I work on it ?
The way I suggested people do this for Xojo Cloud was to something like this:
Dim maintFile as New FolderItem(path, FolderItem.PathModes.Native)
If maintFile.exists then // html for page Response.Write("<html><p>down for maintenance</p></html>") Response.status = 200 Return True End if
Then you only need to create that file to prevent session creation. Once your maintenance is done, remove the file.
If you want to send users to a completely different place, you could also use a temporary redirect inside the id block:
Response.header("Location") = "https://www.example.com" Response.Status = 303 // see other Return True
Note: I used 303 here based on the logic on this page: 307 Temporary Redirect - HTTP | MDN
If your customers use older browsers, change that value to 302.
If you use Lifeboat to deploy your web apps, there is a built in “this application is offline” page that will automatically refresh and load your app when it comes back. Updates are also done in a smart Stop 'n Swop way, so that downtime is merely a second or two when you’re updating an app.
If you plan to have the application offline for extended periods, you can customize the offline page by using a Static Files site instead. This way you don’t have to have a Xojo Web app running to tell your users that the application is under maintenance.
does lifeboat work if the server is on macos ?
I’m sorry, I didn’t know you were using macOS as a server. I didn’t mean to spam.
no problem, your answer is on purpose. I may have a future server on linux.
Sometimes I want to do this and keep the WebApp running. For that situation, I use ths method that send all current users to another WebPage:
Private Function ForceUsersOffline() As integer // forces all users to the offline WebPage // returns the # of users affected dim n as integer For i As Integer = 0 To App.SessionCount - 1 dim sess as session = App.SessionAt(i) // skip users who have the Admin privilege if sess.user <> nil and sess.user.IsAdministrator then continue end if // Without creating a WebSessionContext here, creating // the page would fail triggering a SessionNotAvailableException. Var context As New WebSessionContext(sess) sess.CurrentPage = new wMaintenance // send the user to the 'maintenance' page n = n +1 Next return n End Function