File disappears when not ssh'd - python

So I have tornado server setup on my vps running ubuntu 12.04. So when I am ssh'd into my server or am vnc'd in there the site loads static/templates files just fine. But when I exit out of ssh or terminate vnc python throws error that the file it was looking for does not exist.
[Errno 2] No such file or directory
When I execute the server I just run the python command to run it as a background process, and once its successfully running and exit out.
I have the server running at www.calapp.manangandhi.com
Edit: As per the answer below I was able to figure out a way for it to work. here si the link to daemonizing tornado application, there are other ways suggested in the thread as well. https://groups.google.com/forum/?fromgroups=#!topic/python-tornado/4cxKEFsS0RE

Are you trying to say that you run the server from within the ssh shell? If so, your problem is most likely that on shutdown of the shell, the software gets a HUP and disconnects despite being in the background. You need the software to daemonize and detach completely from the running terminal. If you're using a toolkit, look up "starting as daemon" or launch your software from within DJB's supervise or other system-wide launcher system.

Related

Azure: If I run a program on a VM through a remote desktop's CLI, does that program still run until completion when I close the CLI?

I am trying to run a computationally intensive Python program (which will take several hours) on a virtual machine (VM) through connecting to that virtual machine from a remote desktop's command line interface (CLI), will that Python program continue to run until it finishes, even when I close the CLI?
If not, how can I guarantee that the program will run until completion?
For your question, I assume you use the CLI command az vm run-command invoke to run the scripts in the remote VM, then here is the description:
You can't cancel a running script.
It means if you start running the script in the remote VM, then the script will run until the task finished, even if you close or cancel the CLI command.

Closing Putty window terminates a program

I have a VPS server to which I connect using Putty. There's a python script that has to be running 24/7. But once I close Putty, the script stops.
Is this how it's supposed to work or am I doing something wrong?
For most of the operating systems that you host on your VPS server, with the closing of the putty terminal in your local machine, the process in the server gets killed. For that reason, you need to run the process as a daemon. To make it simpler, you need to run the command in your putty terminal in such a way that if you had control of the remote system's terminal or command line and run a command, closing the terminal or the command line doesn't kill the process there. How to do it is dependent on the operating system that is hosted on the server. Here is a way to start in Unix. Other operating systems enable you to do the same in more or less similar ways, which I will leave for you to research.

WLST disconnect command issue

I had ran wlst.cmd in my local system after I ran my Weblogic Admin Instance. But as WLST is stateful, I am getting connected to my IT env which is my Integration Testing environment (some UNIX machine for my project). I tried disconnect() to goto offline mode, however it is failed.
wls:/beaProjDir/serverConfig> disconnect()
You will need to be connected to a running server to execute this command
Please help to go offline mode in WLST. As I need to get some work done in my local system.
You can try to getting out of WLST Shell ctrl+D. Which is similar to exiting from any other shell.

Connection interrupted when run "indirectly". Bottle.py on Ubuntu

I'm running a local web service on Ubuntu on localhost:8090, written with bottle.py.
The connection uses SSL.
If I execute the main.py file from Nautilus or the terminal and connect to https://localhost:8090 everything works fine.
When I execute it from a link to the file, an .sh script or a .desktop file the server starts running fine, but when I browse to the address firefox says "The connection to localhost:8090 was interrupted while the page was loading"
$telnet 127.0.0.1 8090 gives this:
Trying 127.0.0.1...
Connected to 127.0.0.1...
Escape character is '^]'.
Connection closed by foreign host.
$sudo netstat -ntlupp | grep 8090 gives this:
tcp 0 0 127.0.0.1:8090 0.0.0.0:* LISTEN
iptables is default
I've got the feeling it's blocking the connection when the server is executed "indirectly" (link, script or .desktop), since when I actually click on the file or run it through terminal it runs fine.
I don't have a clue on where to prevent it from blocking the connection, though. Any help is greatly appreciated.
Any workaround will do, even just pretending the file is being run directly from the user.
Thanks in advance
Watch the server logs.
The major difference between the different methods of invocation probably is the current working directory.
I think that it is unlikely that the network configuration is involved in what you are observing.
Depending on the complexity of your web application it might be that a Python import fails if the main script is not run from the right directory. This would trigger a Python exception, which might lead to an immediate connection reset. I have not worked with bottle, but other Python web frameworks distinguish a development mode in which Python tracebacks are shown in the browser, and a production mode in which an HTTP error is sent to the client.
This is what you should do in order to debug your issue: run your server from a terminal (cd to the right directory, then run python application.py). Carefully watch stdout and stderr of that server process while connecting to the web application with your browser.
Ok, problem solved.
It was actually depending on the current working directory not being the same as the python file running the WSGI server.
If I run the .sh script or the link from the same directory everything works fine, and if I give a cd command in the script everything works smoothly.
Thanks for the help Jan-Philip!

to keep the script running even after internet connection goes off

I had putty on one server and run a python script available on that server. That script keep on throwing output on terminal. Later on, my internet connection went off but even then i was expecting my script to complete it job as script is on running on that server. But when internet connection resumed, I found that script has not done its job.
So is this expected ? If yes, then what to do to make sure that script runs on server even though internet connection goes off in-between?
Thanks in advance !!!
You should use screen which will let you "detach" your process from the actual terminal you're in.
On the server, you can install tmux or screen. These programs run the program in the background and enable you to open a 'window', If I use tmux:
Open tmux: tmux
Detach (run in background): press Ctrl-b d
reattach (open a 'window'): tmux attach

Categories