is there a way how to easily run a PHP application as from command line on Windows Azure?
I have a standard Web Application (on Azure) and I want to communicate using WebSockets.
So I need to have a WebSocket Server running all the time on Azure.
I use Wrench project which I need to run “all the time” to listen on some port and deal with messages from JavaScript-sended WebSocket.
So again – how easily run a “persistent” PHP application on Azure?
Thank you in advance.
Sandrino’s answer is fine, but I prefer ProgramEntryPoint for doing this sort of thing. The trouble with a background task is that (unless you build something on your own) nothing is monitoring it. Using
ProgramEntryPoint, Windows Azure will monitor the process, and if it exits for any reason, the role instance will be restarted.EDIT:
Sandrino points out that the PHP program isn’t the only thing running. (There’s also a website.) In that case, I’d recommend launching php.exe in
Run()inWebRole.cs.Process.Startit and then do a.WaitForExit()on it. That way, if the process exits, the role itself will exit fromRun(), causing the role instance to restart. See http://blog.smarx.com/posts/using-other-web-servers-on-windows-azure for an example.