python socket server is killed
I run them as root from shell like so :
python policyServer.py > log1.txt &
python socketServer.py > log2.txt &
Then my flash client can connect and communicate with the sockeServer just fine.
After I left those two python apps running over night and came back this morning both of them were gone from the "top" and the flash client was no longer working.
The python scripts are using non-blocking sockets and just have something like (pseudocode):
while True:
ready_to_read, ready_to_write, in_error = select.select(changed_sockets,[],[])
for s in ready_to_read:
s.read()
Is there a limit to the time a python app can run? Or is something in Linode's system killing scripts that are running for a long time? I want these scripts to run as long as my Linode is running.
Edit found some code that would prevent the scripts from receiving hang up signals going to try with this and see if they still get killed :
nohup python policyServer.py > policyLog.txt &
nohup python simpleServer.py > simpleServerLog.txt &
10 Replies
nohup python server.py &
and see if it makes a difference.
@Finglor:
No I haven't but I highly doubt that's the problem, memory usage is steady at 150mb there are no users except me. Going to try with
nohup python server.py &
and see if it makes a difference.
You are assuming. Assumption is the mother of all fuck-ups.
Nohup only catches hup signals, it would be better to trap signals in your process. My guess is this is either an OOM event or your processes dying due to an internal error.
Right now I create a init script and it runs those 2 python scripts at system boot followed this guide :
Is there some stuff I need to do in my python app too? How do I trap signals in my python app etc.?
@Finglor:
I run them as root from shell like so :
As root!? Whyyy?:(
If they absolutely have to be root to bind a low port, at least drop privileges afterwards.
@Finglor:
Do you guys have some sources that I can read to make it a proper daemon that always runs in the background?
This looks like what you want:
You should work on your google-fu.
I will check this python-deamon thing out.
Thank you.