Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'--dns exec' show output in real time? #2165

Closed
1 task done
kg4zow opened this issue Apr 20, 2024 · 3 comments · Fixed by #2166
Closed
1 task done

'--dns exec' show output in real time? #2165

kg4zow opened this issue Apr 20, 2024 · 3 comments · Fixed by #2166

Comments

@kg4zow
Copy link

kg4zow commented Apr 20, 2024

Welcome

  • Yes, I've searched similar issues on GitHub and didn't find any.

How do you use lego?

Binary

Detailed Description

I'm working on a shell script to use with --dns exec (to manually add/remove DNS records), and running into issues that take significantly longer than they should to debug, because the part of lego which runs my script appears to be gathering the script's output in memory and then dumping it to the output stream all at once. The process of adding/removing DNS records can take up to two minutes per name, so if I'm testing with a certificate having multiple hostnames on it (i.e. name1.domain.xyz, 'name2.domain.xyz, and name3.domain.xyz), I see no output at all for several minutes and then get a dump all at once at the end.

I'm looking at providers/dns/exec/exec.go, but I don't know enough about the exec module to know if this is even possible, so ... is there a way to make the code print each line of input, as soon as the external script prints it?

@kg4zow kg4zow changed the title '--dns exec' show output in real time '--dns exec' show output in real time? Apr 20, 2024
@ldez
Copy link
Member

ldez commented Apr 20, 2024

Hello,

first, what drives you to use exec instead of "real" DNS implementation? Is your provider not supported?

@kg4zow
Copy link
Author

kg4zow commented Apr 21, 2024

Exactly. I've been running my own DNS servers using tinydns for over 20 years. The process of adding a record in tinydns involves (1) adding a line to a text file, and (2) running a command to "compile" the data files into a .cdb file (similar to Berkeley DB).

My own implementation has a Makefile which pushes the .cdb file out to several other machines, and THOSE machines are the public nameservers. My "API server" involves clients using SSH to add and remove records, this has been working for about 10 years when I started using acme.sh. (I'm looking for alternatives, so far lego seems like a better option than certbot but I'm not 100% sold either way - although I do have a bit of a preference for Golang over Python.)

I'm also in the process of learning golang, so it's not impossible that if nobody else has time to look at it, I might take the time to figure it out myself. It looks like I would need to replace the cmd.CombinedOutput() call with cmd.Start(), and add loops or "go-routines" after that which print the STDOUT/STDERR output as it arrives. (I think I see how to do it, it's just not something I've ever done in golang before.)

The other option I'm considering is, instead of writing a script around lego, writing my own client that uses lego as a library. I may do this anyway, but it won't happen any time soon. The only "non-standard" thing I'm doing is the DNS records, so if I can use an established client with a simple plug-in script to handle my own custom needs, I'd rather go that route.

@ldez
Copy link
Member

ldez commented Apr 21, 2024

Thank you for your detailed answer 👍

FYI, I created a PR to stream the script output: #2166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants