YAMJ / yamj-v2

Yet Another Movie Jukebox (YAMJ) v2
GNU General Public License v3.0
28 stars 11 forks source link

Thread-safe, headless version #1334

Open Omertron opened 9 years ago

Omertron commented 9 years ago

Original issue 1335 created by Omertron on 2010-03-09T11:59:17.000Z:

What device are you using YAMJ on? Networked Media Tank, PlayonHD, Other?

Please describe in as much detail as possible what new feature you want:

I'm planning on writing a wrapper to YAMJ and some other utilities useful for generating jukeboxes, and would love to see a headless version able to run side-by-side with itself.

Would this be possible? Or at least be able to redirect the output from the executable to print in other apps?

Omertron commented 9 years ago

Comment #1 originally posted by Omertron on 2010-03-09T12:56:20.000Z:

YAMJ can already run headless. Not sure what you mean otherwise?

Omertron commented 9 years ago

Comment #2 originally posted by Omertron on 2010-03-09T13:05:24.000Z:

Java and by extension YAMJ, write output in "standart" output, so if you redirect standart output it should works.

Feel free to precise you needs, we're here to help :)

Omertron commented 9 years ago

Comment #3 originally posted by Omertron on 2010-03-09T14:04:57.000Z:

Almost all of the YAMJ output is written using the logger. There is very little Stdout output, just the help description and some progress stuff (downloading trailers and copying files)

Omertron commented 9 years ago

Comment #4 originally posted by Omertron on 2010-03-10T06:30:54.000Z:

So, it should be possible to redirect the output to my own program?

Basically, what I would like to do is make a windows app that will generate the jukeboxes automagically. First run YAMJ, then run boxcovers, and then any other software the user wishes for as many jukeboxes they have. It's imperative that this runs as smoothly as possible, which is why I would like to be able to multitask as much as possible and redirect the output to my own app.

Can YAMJ run more than one instance? It didn't use to...?...

Omertron commented 9 years ago

Comment #5 originally posted by Omertron on 2010-03-10T06:57:35.000Z:

No,there's just one thing that is stopping the multi running and that's the temp directories. At the moment, every instance of YAMJ will use the same temp directory which will cause issues. (issue 1279)

Although I suggest that with threading set properly, only one instance should be running because that should be using all of the resources that are available.

Omertron commented 9 years ago

Comment #6 originally posted by Omertron on 2010-03-10T07:14:28.000Z:

I agree...except for one thing - it should be thread-safe ;)

How about implementing something like {tempdir}/{uniqueidentifier}/ for temp? In my case I would very much like to benchmark it to see what I can get the most out of. Maybe running two in parallell if the user has enough cores. That would make it possible to do work and download at the same time.

Do you know how to redirect the output from the logger?

Omertron commented 9 years ago

Comment #7 originally posted by Omertron on 2010-03-14T10:53:30.000Z:

Ok, I've redirected both stdout and stderr (in C¤) and all I get when running YAMJ is "ERROR: The TVDB API -> Server returned HTTP response code: 503 blah blah blah". Just that one line, so I guess stderr is ok, but not the normal output.

Anyone got an idea on how to redirect the output?

Omertron commented 9 years ago

Comment #8 originally posted by Omertron on 2010-03-14T12:03:27.000Z:

The default logging YAMJ use : ConsoleHandler, is supposed to send output to standard err ... it's strange that you didn't get output

Omertron commented 9 years ago

Comment #9 originally posted by Omertron on 2010-03-14T12:06:24.000Z:

Actually, I found a bug in my code (brainfart). I didn't monitor the stderr as I should, so it only checked once. But thanks :)

Omertron commented 9 years ago

Comment #10 originally posted by Omertron on 2010-03-14T12:07:56.000Z:

I just made a test here : ./MovieJukebox.sh . -o ./foo 1>sdt.out 2>sdt.err

i've got all the output in sdt.err file ... i assume you didn't redirect well.

could you give us more information about how you launch yamj ?

Omertron commented 9 years ago

Comment #11 originally posted by Omertron on 2010-03-14T12:20:14.000Z:

        scanProcess.StartInfo.RedirectStandardError = true;
        scanProcess.StartInfo.RedirectStandardOutput = true;
        scanProcess.StartInfo.RedirectStandardInput = true;

        scanProcess.StartInfo.UseShellExecute = false;
        scanProcess.StartInfo.ErrorDialog = false;

Directory.SetCurrentDirectory(@"C:\Users\Lars\Desktop\Popcorn\YAMJ\moviejukebox_v1.7\"); scanProcess.StartInfo.FileName = "\"d:\Program Files (x86)\Java\jre6\bin\java\""; scanProcess.StartInfo.Arguments = @"-Xms256m -Xmx512m -classpath .;resources;lib/* com.moviejukebox.MovieJukebox My_Series.xml -o w:\Jukebox\Series"; scanProcess.StartInfo.CreateNoWindow = true; scanProcess.ErrorDataReceived += new DataReceivedEventHandler(scanProcess_ErrorDataReceived); scanProcess.OutputDataReceived += new DataReceivedEventHandler(scanProcess_OutputDataReceived);

Working now :)

Omertron commented 9 years ago

Comment #12 originally posted by Omertron on 2010-03-14T13:36:18.000Z:

:)

Omertron commented 9 years ago

Comment #13 originally posted by Omertron on 2010-03-14T15:23:08.000Z:

only strange thing is that when I start three threads (2xping and 1xyamj), the yamj thread doesn't seem to be working...The pings, started in the exact same way run along just fine, but yamj hangs after "Jukebox output goes to ..."

Weirdness :S

Omertron commented 9 years ago

Comment #14 originally posted by Omertron on 2010-03-14T15:41:41.000Z:

Hmmm...seems I have to turn down number of threads to one to be able to do this. :S Must find solution! ;)

P.S. The reason I'm "documenting" a little here is that it might be interesting for someone else later on :)

Omertron commented 9 years ago

Comment #15 originally posted by Omertron on 2010-03-14T15:46:54.000Z:

Two more things: would it be possible to have a percentage completeness on stdout, since it's not used? Also, is there a command line option to override the number of threads in the config? Might be useful for other tools as well...