jamesrwhite / minicron

🕰️ Monitor your cron jobs
GNU General Public License v3.0
2.34k stars 154 forks source link

Reverse the order of execution output #174

Closed robinjoseph08 closed 8 years ago

robinjoseph08 commented 8 years ago

Right now, the output of an execution is actually displayed with the first line produced is at the bottom. So the following code:

for (var i = 0; i < 10; i++) {
  console.log('line ' + i);
}

Produces the following:

line 9
line 8
line 7
line 6
line 5
line 4
line 3
line 2
line 1
line 0
jamesrwhite commented 8 years ago

On second thought I can't seem to reproduce what you describe, I tested with minicron run composer and for me it displays as I would expect. See (http://cl.ly/e8RL > http://cl.ly/e8ZU).

jamesrwhite commented 8 years ago

Feel free to re-open if this is still an issue.

robinjoseph08 commented 8 years ago

That's weird... I'm not sure how composer prints out it's contents, but it might print it all out to stdout before it flushes the stream. Try it with echo "hello" && echo "world":

screen shot 2015-12-20 at 9 38 51 pm screen shot 2015-12-20 at 9 39 10 pm
jamesrwhite commented 8 years ago

Weird... still can't reproduce this, the only noticeable difference seems to be you're running the linux build whereas I'm testing this on OSX. Is this version 0.8.4?

image

image

jamesrwhite commented 8 years ago

Even on the linux-x84_64 build I'm still get the expected output ordering, very odd.

robinjoseph08 commented 8 years ago

Yeah, it's v0.8.4. This is strange.

I took a closer look into the setup of things and I think I might have found a possible culprit.

It looks like when the execution outputs are loaded to be displayed, an explicit ordering isn't being set. And without an ORDER BY clause in SQL, there can be no assumptions made about the ordering of the returning rows. I'm using Postgres in my implementation. Are you using SQLite? It might just be the difference in DBs (and the fact I have a lot more outputs in my table) that's causing this.

If you leave the issue open, I should be able to submit a PR by today to fix it.

jamesrwhite commented 8 years ago

Oh that would explain it, I don't test with Postgres very often 😳. MySQL/SQLite default to ascending order by the primary key as far as I'm aware but it should be ordered by the seq field to make sure it maintains the correct ordering. Nice find!