1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-14 22:22:18 +00:00

Fix zombie transcoding processes

Fix various artist album track sorting
This commit is contained in:
Emory P 2014-01-14 00:18:46 -05:00
parent c5890ab120
commit 1f8289e1c6
3 changed files with 15 additions and 5 deletions

View File

@ -34,9 +34,6 @@ def prepare_transcoding_cmdline(base_cmdline, input_file, input_format, output_f
return base_cmdline.replace('%srcpath', '"'+input_file+'"').replace('%srcfmt', input_format).replace('%outfmt', output_format).replace('%outrate', str(output_bitrate)) return base_cmdline.replace('%srcpath', '"'+input_file+'"').replace('%srcfmt', input_format).replace('%outfmt', output_format).replace('%outrate', str(output_bitrate))
def transcode(process):
for chunk in iter(process, ''):
yield chunk
@app.route('/rest/stream.view', methods = [ 'GET', 'POST' ]) @app.route('/rest/stream.view', methods = [ 'GET', 'POST' ])
def stream_media(): def stream_media():
@ -51,6 +48,17 @@ def stream_media():
response.headers['X-Accel-Redirect'] = redirect + xsendfile.encode('UTF8') response.headers['X-Accel-Redirect'] = redirect + xsendfile.encode('UTF8')
app.logger.debug('X-Accel-Redirect: ' + redirect + xsendfile) app.logger.debug('X-Accel-Redirect: ' + redirect + xsendfile)
return response return response
def transcode(process):
try:
for chunk in iter(process.stdout.readline, ''):
yield chunk
process.wait()
except:
app.logger.debug('transcoding timeout, killing process')
process.terminate()
process.wait()
status, res = get_entity(request, Track) status, res = get_entity(request, Track)
if not status: if not status:
@ -137,7 +145,7 @@ def stream_media():
dec_proc = subprocess.Popen(decoder, stdout = subprocess.PIPE, shell=False) dec_proc = subprocess.Popen(decoder, stdout = subprocess.PIPE, shell=False)
proc = subprocess.Popen(encoder, stdin = dec_proc.stdout, stdout = subprocess.PIPE, shell=False) proc = subprocess.Popen(encoder, stdin = dec_proc.stdout, stdout = subprocess.PIPE, shell=False)
response = Response(transcode(proc.stdout.readline), 200, {'Content-Type': dst_mimetype, 'X-Content-Duration': str(duration)}) response = Response(transcode(proc), 200, {'Content-Type': dst_mimetype, 'X-Content-Duration': str(duration)})
except: except:
return request.error_formatter(0, 'Error while running the transcoding process') return request.error_formatter(0, 'Error while running the transcoding process')

3
db.py
View File

@ -289,7 +289,8 @@ class Track(database.Model):
return os.path.splitext(self.path)[1][1:].lower() return os.path.splitext(self.path)[1][1:].lower()
def sort_key(self): def sort_key(self):
return (self.album.artist.name + self.album.name + ("%02i" % self.disc) + ("%02i" % self.number) + self.title).lower() #return (self.album.artist.name + self.album.name + ("%02i" % self.disc) + ("%02i" % self.number) + self.title).lower()
return (self.album.name + ("%02i" % self.disc) + ("%02i" % self.number) + self.title).lower()
class StarredFolder(database.Model): class StarredFolder(database.Model):

View File

@ -11,3 +11,4 @@
processes = 8 processes = 8
harakiri = 60 harakiri = 60
daemonize = uwsgi.log daemonize = uwsgi.log
close-on-exec = true