GithubHelp home page GithubHelp logo

Writing to a named pipe about joy HOT 15 CLOSED

cisco avatar cisco commented on July 30, 2024
Writing to a named pipe

from joy.

Comments (15)

JohnOmernik avatar JohnOmernik commented on July 30, 2024 1

I am not not afraid to write C, I am afraid to push C to any sort of public repo... I looked at src/p2f.c and don't see where the actual output file is being opened. I am looking for that and I will just hard code (for my use) the setbuf(f, NULL) right after it's opened so I know I don't have buffering.

from joy.

bhudson33 avatar bhudson33 commented on July 30, 2024 1

from joy.

fliphil avatar fliphil commented on July 30, 2024

I'm not sure what it is that you're asking. Can you be more specific?

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

I am noticing when I am running joy with the output set to a named pipe created with mkfifo (with no rotation etc set, and compressed output = 0) Records appear to be buffering somewhere. If I exit joy, a bunch write, or if a pile of records get written, there seems to be a flush, but it seems to be buffering. (this is monitoring the pipe with tail -f)

It's the difference between when I run a python script with output, and I don't want buffered output, I just python -u myscript.py and it just writes direct.

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

Also, I during the tail -f I will get "incomplete" records as it purges the buffer, but part of a record is in one dump of the buffer and the rest is in the next buffer. By doing unbuffered writes, it ensure only full records get written

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

Basically, I see output buffering is disabled in DEBUG mode, can we get a flag to disable output buffering but not have DEBUG mode turned on. (I can read C code, I am afraid to write it though...

/* in debug mode, turn off output buffering */

#if P2F_DEBUG
setvbuf(stderr, NULL, _IONBF, 0);
setbuf(stdout, NULL);

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

Line 432 in https://github.com/cisco/joy/blob/master/src/joy.c

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

This is where my C hacking sucks... so that's just for stdout, but I need to find the place that the outputfile for the JSON records is opened, and provide either an option to disabled buffering or just hack this into the file where the output is opened... that way it will write unbuffered... I didn't see that in joy.c, can you point me in the right direction to see where the output file is opened? Thanks!

setbuf(f, NULL);

from joy.

fliphil avatar fliphil commented on July 30, 2024

You shouldn't be afraid to write C code, in fact I recommend that you learn how to. It appears to me that you have an good idea of how to change the code to suit your specific needs.

Fixing bugs is one thing, but feature requests is entirely up to you to implement or at least partially contribute code. My team and I simply do not have the bandwidth to drop what we are doing and make changes such as this. Joy is offered as open-source to encourage people such as yourself to advance the project for the whole user base, not to be used as a service.

I look forward to seeing a pull-request from you in the future!

Philip

from joy.

fliphil avatar fliphil commented on July 30, 2024

You may want to take a look at src/p2f.c because that is where the flow_records are being written.

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

Does it use zopen if I set compression = 0 in the input.h? This is where I am confused by the compile time compression...

from joy.

fliphil avatar fliphil commented on July 30, 2024

Yes it will still use zopen, but the macro definition changes. With compression = 0 it will define to fopen, and if compression = 1, it will be gzopen.

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

Ah cool

Trying now

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

So I tried putting the setbuf(output, NULL); in both places zopen was called in joy.c, and I am still getting buffered output. I would like to live tail this log, and the partial records is troublesome. I will continue to troubleshoot on my side, but if anyone else any ideas where I could disable buffering I would be very appreciative I am just guess and checking at this point.

from joy.

JohnOmernik avatar JohnOmernik commented on July 30, 2024

I think it's working now... doing testing. (the original suggestion worked, I just um, tested with the wrong binary... *sigh

from joy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.