Over the years I have learnt to make smaller size docker images which have usually worked well for me and I have been able to reduce my image files from GBs in size to few hundred MBs. I recently found an article which summarizes these best practices in an easy to use approach.
Author Archives: cyberaka
Spring Cloud Configuration Issue
For a new project I was trying to setup a config server to connect my services together. Although the spring-cloud-config server works fine, I am not able to make my service talk to the config-server which is really strange as I am fairly well versed with Spring Cloud and usually setting up a dev environment is a no-brainer.
I have described my issue in stackoverflow to get help and I am debugging in parallel as well.
Bye Bye Hystrix
Hystrix used to be my tool of choice for implementing circuit breakers in my Spring Boot application. However there has been literally no commits in Hystrix github repo for past 1 year. It seems Netflix has moved on to resilience4j which will be actively maintained.
Resilience4j commit log is quite active and a lot of active work is going on in it.
However it should be noted that there is another mature library named Sentinel which seems to be quite feature rich and very well supported. It has been battle tested by Alibaba which is huge. In my next project I would be considering both Sentinel and Resilience4J in my choice for a reliable circuit breaker for my application.
Taking backup zip from multi-module Java project
I like to keep an archive of my code on a monthly basis. I wrote a small bash script to create zip out of my multi module Java projects. It gets the job done and can be improved to include resources and test folders as well. As of now I am only interested in the Java code zip backup.
!/bin/bash if [ -d "combined" ]; then echo "Removing existing zip files in combined .." rm combined/*.zip else echo "Creating combined folder.." mkdir combined fi for d in */ ; do if [ -d "$d/src/main/java" ]; then var="$(echo $d | sed 's/.$//')" echo "Processing $var .." cd $d/src/main/java zip -r ../../../../combined/$var.zip com cd ../../../.. else echo "Ignoring .. $d" fi done
Handling Certificate Issue In Maven Build
When building a new Java project I ended up facing some certificate error. I resolved it by using this article which is quite well written.
ASCII Art
Found a good tool to generate ASCII Art for command line applications. I found the Doom font to be good.
Good Tool For Conversion Requirements of Coders
I was looking for a way to convert some XML data to JSON a I stumbled about https://codebeautify.org/ which did exactly what I wanted. It seems to have a lot of other toolkit which can be used for different types of conversion which a programmer can need.
ssh_exchange_identification: read: Connection reset by peer
I recently upgraded my Mac Desktop and I noticed a strange problem that I was not able to SSH into my desktop from my laptop. I ultimately found out that the SSH setup that came with MacOS was having some issue as when I did ssh user@localhost on the desktop I got the same error:
ssh_exchange_identification: read: Connection reset by peer
I ended up tailing the system log using the following command:
sudo tail -f /var/log/system.log
I observed the following entries in the log whenever a SSH was attempted.
com.apple.xpc.launchd[1] (com.openssh.sshd.[UUID][NUM]): Service exited with abnormal code: 1
It was clear that there was setup issue with the SSH that came with default MacOS installation. So I decided to spawn a separate SSH instance and watch it’s log:
sudo /usr/sbin/sshd -d -p 2222
This command showed up a lot of issues related to file permissions.
Permissions 0644 for '/etc/ssh/ssh_host_dsa_key' are too open.
Permissions 0644 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
Permissions 0644 for '/etc/ssh/ssh_host_ed25519_key' are too open.
I fixed these permission issues by changing their permission to 400:
sudo chmod 400 /etc/ssh/ssh_host_dsa_key
sudo chmod 400 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 400 /etc/ssh/ssh_host_ed25519_key
After this change the following command succeeded and I was able to do successful SSH connection to port 2222.
sudo /usr/sbin/sshd -d -p 2222
So I killed this process and decided to restart SSH:
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo lsof -i:22
echo $?
sudo launchctl load /System/Library/LaunchDaemons/ssh.plist
Once SSHD was restarted I could successfully do logins using ssh user@localhost from Desktop as well as remote login via SSH from my laptop.
Amazon Corretto – Open JDK
Read through a DZone article which talks about a JDK released by Amazon called Amazon Corretto. This is a good news for Java community. It is a production ready JDK backed by Amazon and has been tested heavily by them. This is really an exciting development.
Prettify JSON on Terminal
I love using curl command on my Mac terminal to debug my REST endpoints. However the REST call JSON output used to come in a blob of text which required further formatting in an Editor like Visual Studio Code. To allay this problem I ended up installing “jsonpp” using homebrew.
brew install jsonpp
So now I just pipe the output of my curl command to the jsonpp program and I get a fully formatted JSON.
$ curl http://localhost:8080/test | jsonpp
{
"year": 2018,
"month": 2,
"worked": 18,
"leaves": 2
}