dgrant / eyefiserver2

A standalone Eye-Fi server in Python, for Linux
GNU General Public License v3.0
140 stars 40 forks source link

Can't stop server #10

Open dgrant opened 10 years ago

dgrant commented 10 years ago

eyefiserver2 can't be stopped using init.d script (needs to be -9'd). This only seems to apply after a photo has been uploaded. If not uploading has occurred then it will shut down.

robin13 commented 10 years ago

Same for me.

dgrant commented 10 years ago

I haven't touched this because someone had offered to fix this, but I haven't heard from him in a long time. I'll have a look.

mothy60 commented 10 years ago

I've also got this problem, however I get it even if no photo has been uploaded. and even if i run the script with init.d.

stooboy commented 10 years ago

hello, i have the same issue but it also stops my ubuntu install from shuting down also. unbuntu 14.10 seems to happen weather a pic is uploaded or not.

dgrant commented 10 years ago

I'm working on it. I tried last night and the only solution I have so far is to close the socket. Not pretty, but will do for bow. Hopefully I'll have a commit in for this today for you to try.

Dave On Sep 3, 2014 1:37 PM, "stooboy" notifications@github.com wrote:

hello, i have the same issue but it also stops my ubuntu install from shuting down also. unbuntu 14.10 seems to happen weather a pic is uploaded or not.

— Reply to this email directly or view it on GitHub https://github.com/dgrant/eyefiserver2/issues/10#issuecomment-54362042.

dgrant commented 10 years ago

Can anyone test this fix? https://github.com/dgrant/eyefiserver2/blob/issue10_cant_stop_server/usr/local/bin/eyefiserver.py

dgrant commented 10 years ago

This is the commit: https://github.com/dgrant/eyefiserver2/commit/ca62c8ed7b31526f634c84c2176184a23fdb419e

stooboy commented 10 years ago

Hello, I have aplied the update and although i still get the unexpected error the server does now exit, and allows my pc to shutdown. :) thanks

dgrant commented 10 years ago

What error do you get? Glad it works! On Sep 5, 2014 4:35 AM, "stooboy" notifications@github.com wrote:

Hello, I have aplied the update and although i still get the unexpected error the server does now exit, and allows my pc to shutdown. :) thanks

— Reply to this email directly or view it on GitHub https://github.com/dgrant/eyefiserver2/issues/10#issuecomment-54614391.

stooboy commented 10 years ago

Hi,

There error was "/etc/init.d/eyefiserver: 20: [: TRUE: unexpected operator"

and never exited, either when a picture was sent or not.

I just tried it again after a reboot and took a picture, and its not exiting.

if i take no photo and stop the server its gives the unexpected error followed with eyefi server stopped.

leshus commented 10 years ago

No, it's not works for me... It works only if you start the server and stop immediately... (as well exception report)

./eyefiserver.py instance eyefiserver.conf eyefiserver.log
[09/05/14 07:25PM][runEyeFi] - Reading config eyefiserver.conf
[09/05/14 07:25PM][runEyeFi] - Eye-Fi server started listening on port 59278
^C
[09/05/14 07:27PM][stop_server] - Eye-Fi server stopped 
[09/05/14 07:27PM][serve_forever] - Swallowing exception, perhaps socket closed: [Errno 9] Bad file descriptor

If you try start the server, upload photo and then stop the server it is not works... have to call kill -9 PID

p.s. i'm also change upsyncallowedElementText = doc.createTextNode("true") again (without mod, upload not started)

System info: Ubuntu 14.04.1 (Linux 3.13.0-35-generic #62-Ubuntu x86_64 GNU/Linux) Card info: Eye-Fi Card/5.0019

dgrant commented 10 years ago

Sorry, I guess I'll have to do some more fiddling and actually upload photos. Sorry I can't get to this right away. It's an open source project so anyone is free to help, although I realize not everyone is a coder. Thanks for your help reporting and testing.

jharris0221 commented 9 years ago

Any progress on this? Seems to still be an issue. Appreciate you working on it!

dukesrg commented 9 years ago

Just realized stopEyeFi() is never called, so does do_Quit in turn. Shouldn't be a shutdown() call for BaseHTTPServer instance? Looks like all daemon and sigterm stuff is working fine but BaseHTTPServer is locking the thread.

dgrant commented 9 years ago

Any work on this is much appreciated. I spent some time on this on a branch but didn't get it completely fixed.

dukesrg commented 9 years ago

I googled for that problem, and found that basehttpserver must be requested from the local host to exit the serve loop. Looks like QUIT method was intended to do so, but never called now. The other method was to invoke a shutdown(). the third issue may be related with the linux double fork used that sometimes result in zombifying the second one. But on the other hand serve_forever is started with tha damon and exits properly if there was not any request served and those do not looks like our case. I tried the first two workaround and it didn't work or I got an exceptios, but I'm not a Python programmer so may did a mistakes.

dgrant commented 9 years ago

I should have provided more detail. I also noticed the QUIT method which was intended to send the request which will exit the loop but I couldn't get it to work either.

On Mon, Oct 27, 2014 at 9:46 PM, dukesrg notifications@github.com wrote:

I googled for that problem, and found that basehttpserver must be requested from the local host to exit the serve loop. Looks like QUIT method was intended to do so, but never called now. The other method was to invoke a shutdown(). the third issue may be related with the linux double fork used that sometimes result in zombifying the second one. But on the other hand serve_forever is started with tha damon and exits properly if there was not any request served and those do not looks like our case. I tried the first two workaround and it didn't work or I got an exceptios, but I'm not a Python programmer so may did a mistakes.

— Reply to this email directly or view it on GitHub https://github.com/dgrant/eyefiserver2/issues/10#issuecomment-60709508.

David Grant http://www.davidgrant.ca

prestigez commented 9 years ago

I also get this error when I stop eyefiserver 20: [: TRUE: unexpected operator

and finally I can't stop it I have to kill process "kill -9 pid" and service eyefiserver stop after that.

aflat commented 9 years ago

If I change line 181 from

os.kill(pid, SIGTERM)

to

os.kill(pid, signal.SIGQUIT)

It shuts down fine, and doesn't core dump either. Tested on Mint17, and Fedora 19.

aflat commented 9 years ago

Looks like that change doesn't allow the server to stop after I upload a pic, so back to the drawing board.

dgrant commented 9 years ago

Thanks for trying. :-) On Jan 20, 2015 8:37 PM, "George" notifications@github.com wrote:

Looks like that change doesn't allow the server to stop after I upload a pic, so back to the drawing board.

— Reply to this email directly or view it on GitHub https://github.com/dgrant/eyefiserver2/issues/10#issuecomment-70783405.

aflat commented 9 years ago

Ok, not nearly as nice, it's just killing it, but that's what I have to do anyways.

os.kill(pid, 9)

works, even after I upload a picture. It does clean up the pidfile too.

ryantm commented 9 years ago

I can confirm that when running as an instance and doing ctrl-c after uploading a picture with this bug fix branch, it doesn't kill it.

Sklanfurt commented 7 years ago

Got the script running but my computer wont shut down after it started. Have to kill it everytime. Somebody got a solution for this?

ryantm commented 7 years ago

@Sklanfurt My solution was to write my own server. The code is at https://github.com/ryantm/heyefi

dgrant commented 7 years ago

@ryantm in Haskell! :raised_hands:

dgrant commented 7 years ago

Yeah this bug sucks, I can't even reboot my NAS, I always have to ssh in to it and stop it before doing a reboot otherwise it will never shut down. I spend some time trying to fix it a while back and failed.