If you’re in tech, you have probably heard about how a programmer connected a thermal printer to his Jira and GitHub issues.
This sparked the interest of my client’s department head, Shlomi Horev, who decided to give me a challenge – make one of these for us.
How I started
So I read this guy’s article and he mentioned ESC/POS, being the standard for Epson POS printers.
I don’t know PHP and while I love learning, I can’t spread myself too thin between dozens of subjects, and since I’ve already been studying Go, I decided to see if there were any libraries for controlling ESC/POS printers with Go.
(even though following my last post, I was kind of tempted to straight up send raw escape codes to the printer, but as I always say, just because you can, doesn’t mean you should…)
We use Jira, so I looked up how to use Jira’s webhooks, spun up a simple web server, and started parsing the sent data so that I could see which fields I can access and how.
While testing, I needed to think of a way to get this working at home, and settled on implementing remote SSH tunelling between my Linux PC, and an Ubuntu server in Azure.
Shopping list
- Ubuntu server with a public DNS name and IP address
- SSL certificate & private key
- ESC/POS-compliant thermal printer (Here’s mine)
- Linux computer to connect the printer to (I would’ve used RPi Zero if it wasn’t sold out)
- Jira (duh!)
Issues I have encountered
It’s a bit emberrasing to admit but what took me the most time to figure out was where the heck under /dev
my printer was. Once I figured that out I needed to understand how to perform reverse SSH forwarding, because I have read about someone who hosted his personal website on an old Macbook using this method but I have never done it myself before.
The last thing I needed to do was figure out how to print a QR code with a link to the issue, since the function for printing a QR code in the library I used didn’t work. I eventually circumvented this by creating a byte slice holding the QR code as image data and printed the image which did work succesfully.
Being a DevOps engineer, I honestly felt uneasy just spinning at a virtual machine in the cloud (what is this? the 2010s?), and I tried making a lightweight Alpine-based container as the SSH forwarder in the cloud. I couldn’t get that to work and eventually left it as a small VM (which was also cheaper).
So, was it worth it?
I’d say that’s a definite yes, it was a nice weekend project and I learned a lot, and after finishing touches, I let myself have at it and printed my favorite character, Dog of Wisdom.
The code (along with a readme detailing how to set up an instance of your own) is, of course, available in my GitHub repo.
Now all that’s left is to change the configuration file to suit my client’s needs, and viola!
One response
Doing amazing things as always.