views:

45

answers:

1

My Django app stops working when deployed on Apache ( with mod_wsgi ). It runs on a Windows server. The app calls on a windows executable called "rex" ( Alchemy Remote Executor ) which executes a command on another remote windows box.

process  = subprocess.Popen( ['rex',ip,usr,pwd,command], stdout=subprocess.PIPE, universal_newlines=True )
out, err = process.communicate() 

This all works fine in development, but when deployed on Apache with mod_wsgi, it doesn't work! The "rex" program still runs, but it fails to do it's thing, and gives the following message:

Failed to execute the program: A specified logon session does not exist. It may already have been terminated.

So, the "rex" program is running, but it is not able to make the required connections or something when it's spawned from Apache. It almost seems like Apache is somehow closing the connection made by "rex.exe" before it can finish!

Any ideas?

A: 

It's always a challenge when deploying to a windows service that you are running as a different user than you're running under when you are in development, running it as a real user. I've had all kinds of troubles with this writing an updater that runs as a service, getting file permissions problems. Can you try logging in to Windows as the same user that is running the Apache service, and try your rex executable from there? With luck, you might be able to get rex to fail there where you're interactive and can troubleshoot it.

But the basic idea is to replicate the failure outside of the apache service, then do whatever is needed to let this thing run while under the permissions of the service, and you're fixed. It could be that your rex program is trying to read or write to files (such as configuration files?) that it doesn't have permissions for.

Unoti
Thanks for your answer, but I don't think it's about permissions. Apache service was running as "system user account" or something (how to login as that user?). I did try running Apache under my own account, and I got the same result. I think it's something to do with network connections -- the process spawned from Apache can't keep a connection open. Are there restrictions placed upon such processes? Are there blocked ports?
Nick Perkins