Parameter 'stdout' is not working

10 views
Skip to first unread message

bessarabov

unread,
Mar 19, 2014, 1:55:28 AM3/19/14
to ubic...@googlegroups.com
I've installed ubic from ppa to ubuntu 12.04.

Then I've created file /etc/ubic/service/tmp:

    use Ubic::Service::SimpleDaemon;

    my $service = Ubic::Service::SimpleDaemon->new(
        bin => qq/perl -e 'while (1) { print time . "\n"; sleep 1; }'/,

        stdout => "/tmp/tmp-out.log",
        stderr => "/tmp/tmp-err.log",
        ubic_log => "/tmp/tmp-ubic.log",
    );

Afther I ran `sudo ubic start tmp` the file '/tmp/tmp-out.log' is created, but I has no content.

If I change the bin command to:

    bin => qq/perl -e 'while (1) { warn time . "\n"; sleep 1; }'/,

And restart service, then I get what I expect in the file "/tmp/tmp-err.log".

Can you please help me with this behaviour.

Vyacheslav Matyukhin

unread,
Mar 19, 2014, 5:51:13 AM3/19/14
to ubic...@googlegroups.com
That's because of buffering policies in perl: stderr is never buffered, stdout is buffered only if the output is not a terminal.
perl -e 'STDOUT->autoflush(1); ...' should fix this issue. (With additional 'use IO::Handle' if you care about compatibility with older perl versions.)
 
19.03.2014, 09:55, "bessarabov" <ivanbes...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Ubic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ubic-perl+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Иван Бессарабов

unread,
Mar 23, 2014, 9:04:46 AM3/23/14
to ubic...@googlegroups.com
Thank you for your explanation!
Reply all
Reply to author
Forward
0 new messages