1

I've been developing some sites using Flask recently (running on debian within a virtualenv), and when I am testing I can run it on a port, let's say post 5000.

So I run the script like so:

. env/bin/activate           <- go into virtual environment
python file.py               <- run python script

And I will be given this message:

Running on http://0.0.0.0:5000/

So this all works great and I can access my site on this port fine. However... my rubbish ISP always does this thing where it resets something around 1am every morning. I have no idea what this is, everything runs like normal but I always get disconnected from any SSH sessions open. This leaves it running and all I can do is call:

lsof -i

Which will show me the process but if I kill it and then rerun it things get weird. The:

Running on http://0.0.0.0:5000

message still shows but I cannot connect to it anymore. I've tried changing the port number and it seems the only thing that works is trying again later on or on another day. Now I'm assuming that something on my server resets inbetween these times and I would like to think it was maybe that virtualenv session timing out, but I cannot find out how to do this manually, does anyone know?

1 Answer 1

2

I am not sure what's going on there but if you have an unstable ssh connection, use tmux.

tmux

It will open a terminal session that is inside of a container that you can reconnect to later. Anything running inside that virtual terminal will keep running if the session disconnects. So after you are kicked out, ssh back in and run

tmux attach

then you will pick up right where you left off.

There's another, older program that does this also called "screen" but while is is more common to find, it isn't actively maintained.

3
  • Hey, yea I've heard of screen but I'll give tmux a go. I don't have a unstable ssh connecter per-say, it's just my ISP seems to do something every night at exactly 1am. It doesn't seem to matter what SSH is connected, it will d/c at that time!
    – ingh.am
    Jul 1, 2012 at 0:35
  • tmux (or screen) will prevent the session from dying so that your process survives whatever they are doing.
    – MichaelB
    Jul 1, 2012 at 1:22
  • Thanks seems to work fine. I will accept this as the answer although I would still love to know if anyone else has come across this (msg for future readers!)
    – ingh.am
    Jul 1, 2012 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .