geekmaster / eyefiserver2

Automatically exported from code.google.com/p/eyefiserver2
0 stars 0 forks source link

Clean shutdown of the server #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I need the script to be daemonized with ability to shutdown (not killing it).
When start the server as daemon, you loose the refference to it.
In order to shutdown it, you need to send a special command via http to tell 
server to shutdown itself.
I may share my code.

Original issue reported on code.google.com by vilius.s...@gmail.com on 16 May 2012 at 10:24

GoogleCodeExporter commented 8 years ago
Eyefi python script has been daemonized, allthough startup script was not 
tested, as I use different enviroment. Pid file is not needed anymore.
normally server shutdown should look like this:
eyfiserver.py stop conf_file log_file

David, please test it on you machine. Modify startup file if needed.

Original comment by vilius.s...@gmail.com on 21 May 2012 at 8:44

GoogleCodeExporter commented 8 years ago
I'd like to understand better the reason for putting the daemonization logic 
inside the script? The init.d script already does the daemonization.

With your code is it necessary to send the http request to shut it down? I'll 
have a closer look at the code now.

There is also a standard daemon library, 
http://pypi.python.org/pypi/python-daemon/, although I can understand that not 
having any dependencies is an advantage. One solution to this would be to 
package up these external scripts with eyefiserver.

Original comment by davidgrant on 22 May 2012 at 1:46

GoogleCodeExporter commented 8 years ago
I have a very limited envirnment on my Qnap NAS so I lack some of the Python 
libraries (like pyexiv2) and Linux tools.
I don't have start-stop-daemon tool and I couldn't find any alternative, so I 
had to workaround this.
The solution is pretty simple - I use daemonization class wrapper which creates 
the daemon for server. Notice, that I do not have Pid file so I dont know the 
process id. Besides, I want to shutdown the server, not to kill it.
In order to shutdown the server I have to find and access the server process, 
therefore I send a http QUIT command to server process. The server does the 
rest.
This example was taken form the internet and as far as I can see from the code, 
authors idea of the primary code was the same.

Original comment by vilius.s...@gmail.com on 22 May 2012 at 7:51

GoogleCodeExporter commented 8 years ago
Thanks for the info. I didn't realize that even start-stop-daemon tool was not 
available.

I have seen other processes offer a "-d" (run as daemon) switch. Perhaps we 
could do the same thing, so that we can choose whether to run as daemon or not. 
I will add some better command-line parsing and stuff.

Just curious, what version of Python is running on your Qnap NAS? This will 
affect what command-line argument parsing library I use (optparse vs. 
argparse). Actually can you verify whether either of those libraries are 
installed in its python distribution? It's possible that one or both are 
missing. I have seen argparse missing on an ARM python package even though it 
was 2.7.

Original comment by davidgrant on 22 May 2012 at 3:54

GoogleCodeExporter commented 8 years ago
Issue 4 has been merged into this issue.

Original comment by vilius.s...@gmail.com on 22 May 2012 at 4:00