Launch Web App from Desktop App

Hi,

I have written a Desktop Application… To let users control that application remotely I have written a Xojo Web App that communicates with my server app using IPCSockets.

Now I want to include the Web App in my Application Bundle and let my Desktop App launch and quit the Web App.

So my question is: How do a do that the best way? (I rather not use folderitem.launch since it opens the terminal window, I’d prefer if the Web App can be kept hidden.)

Dan

Bump…

Maybe you can launch it in a shell if it’s a stand alone WE app?

Well, I have been trying to use that but I don’t seem to get it to work properly in SHell.Mode=1 (Async).

The Web App does not stay alive - guess I must do some more reading in the manual :slight_smile:

Think I’ve found my problem

Shell.Execute "HelloWorld" //I need to do something like this to keep the shell with my Web App alive while Shell.IsRunning Shell.Poll wend

Try putting the shell property into a module somewhere and then setting it to nil when you want to kill the web app. It’s probably the fact that it’s going out of scope that’s shutting down the app.

Also, keep in mind that the environment of a shell is not the same as if you opened a terminal.

BTW, can you show us what command you are using to start up the web app?

I have put the Shell into a thread.

I stop the WebServer by using Shell.Close

I launch the Web App like this:

Shell.Mode=1 vShellPath=WebServerFolderItem.ShellPath + " --port=" + str(vPort) Shell.Execute vShellPath

And actually it works rather good as it is right now.

That while loop you’ve got there… Isn’t your thread consuming a lot of CPU with such a tight loop?

Good question. I changed it so it actually looks more like this now:

In the Run event of thread: (pWebServerShell is a property)

[code] pWebServerShell.Execute vShellPath
while pWebServerShell.Execute.IsRunning

pWebServerShell.Poll

me.Sleep 1000,true

wend[/code]

The code posted above consumed a lot of CPU so I changed it to:

me.Sleep 1000,false

Now it behaves really nice.

The true value tells the thread that it can wake early if the CPU cycles are available. You might also find that a lower sleep value will make he shell more responsive and not hurt performance that much.

Now i have started to try to launch my Web Server on Windows as well. (Above was Mac).

It works fine to begin with but when I close my shell the Web Server keeps running on Windows.

And if I quit my main application, the one that creates the shell and launches the Web Server the Web Server keeps running so I have to kill it from the Activity monitor.

I think that according to the documentation it should behave similar on Windows as it does on the Mac?

[quote=176840:@Dan Berghult]Now i have started to try to launch my Web Server on Windows as well. (Above was Mac).

It works fine to begin with but when I close my shell the Web Server keeps running on Windows.

And if I quit my main application, the one that creates the shell and launches the Web Server the Web Server keeps running so I have to kill it from the Activity monitor.

I think that according to the documentation it should behave similar on Windows as it does on the Mac?[/quote]

That is the normal behavior under Windows. I can’t recall exactly what Norman said about the difference, but essentially under Mac OS X and Linux a shell is a child process, whereas in Windows it is on it’s own. You can kill the launched web app from the shell with TaskKill, or add some code to it and your desktop app with IPC to tell it to quit.

Thanks!