OliverF/mjpeg-relay

running in background

Opened this issue · 4 comments

I can´t run it in background.
If I do with nohup python relay.py "http://user:pwd" &@ip..." & I get "'nohup python relay.py -d "http:…' has stopped" and in nohup.out the following:
Traceback (most recent call last):
File "relay.py", line 82, in
while raw_input() != "quit":
IOError: [Errno 9] Bad file descriptor

Thanks for the report. This makes sense because there is nothing to read from in background mode. I'll have to add something to detect if we're running in such a situation. In the meantime a fix would be to use screen or tmux.

screen is working great. thx for the workaround and of course for mjpeg-relay ;)

I'm trying to run this as a background service but nothing I try will keep it running for more than maybe 15 minutes at a time.

Running it as a systemd service results in systemd restarting it repeatedly until the restart limit is reached, then systemd says that it failed, with "Main process exited, code=exited, status=1". If I try simply running the Python script on the command line (within screen), it works fine for a while but eventually ends up exiting with no indication of why (following is with debug mode enabled):

Starting new HTTP connection (1): 90.x.x.x
send: 'GET /?action=stream HTTP/1.1\r\nHost: 90.x.x.x:8080\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.10.0\r\nAuthorization: Basic Og==\r\n\r\n'
reply: 'HTTP/1.0 200 OK\r\n'
header: Access-Control-Allow-Origin: *
header: Connection: close
header: Server: MJPG-Streamer/0.2
header: Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0
header: Pragma: no-cache
header: Expires: Mon, 3 Jan 2000 12:34:56 GMT
header: Content-Type: multipart/x-mixed-replace;boundary=boundarydonotcross
"GET /?action=stream HTTP/1.1" 200 None
Connected to stream source, boundary separator: --boundarydonotcross
Client left. Client count: 2

This is with mjpeg-relay connecting to a Raspberry Pi running mjpg-streamer, which I suspect will be the standard way for anyone to be getting a mjpeg stream from a Pi. I'll have both ZoneMinder and a Chrome browser connected as clients for mjpeg-relay, although the Chrome connection tends to be closed by the time that mjpeg-relay exits.

Any ideas? Thanks :)

It needs stdin stream... Else it will crash...

#22 (comment)