I tried to use Zookeeper as Dubbo registry. The official documentation suggests maven dependency as show below:


But this won’t work, because the Dubbo source code has already changed its dependency to org.apache.curator

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.CuratorWatcher;
import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;

So how about this?


5.1.0 is the latest version of Apache Curator, but this still won’t work, because `org.apache.curator.framework.recipes.*` is not part of the curator-framework. You need to add…

I tried to log every POST requests of my Spring MVC projects. Not feeling like to add logger.trace(...) at every POST entry, I decided to learn how to use Spring AOP to advice all the methods annotated with @PostMapping.

The first thing to do is to add the maven dependency.


After that, I created a class called PostRequestLogger.

public class PostRequestLogger {

The @Component annotation is required here. Without it, this aspect won’t be registered.

Next, defining the pointcut.

public void postAction() {

Spring AOP only supports method join point if…

The fat jar created by Spring-boot is great. You throw it into the server, start it with java -jar fat.jar, and you are done. But how do you restart the service? ps aux | grep xx | grep -v grep | awk xxx | kill xxx It’s very ugly. I don’t like it. Besides, should the JVM or server crashes and restarts, you have to start the service manually.

What I need is register this jar as a minimum Systemd service.

Description=I am very lazy
ExecStart=/usr/bin/java -jar /path/to/jar/location

Put this configuration file in /etc/systemd/system/myservice.service, then…

The first step is to install erlang. But you don’t want to install this

yum install erlang

It’s super old, erlang14 to be exact. The best way I found was to use rabbitmq-erlang:

But oh boy I don’t understand the readme instructions. Maybe it’s because I am not familiar with CentOS at all. After a very frustrating morning, here is what I did:

Download the rabbitmq-erlang rpm directly


Install It

yum install erlang-21.0.8-1.el6.x86_64.rpm

If you encounter a conflicts error, try this:

yum remove erlang-erts-R14B-04.3.el6.x86_64

Download the rabbitmq-server rpm directly


Install It

yum install rabbitmq-server-3.7.3-1.el6.noarch.rpm

Yesterday Webstorm stopped follow the breakpoints in the source code while I was debugging. The source code is compiled with babel and placed in the dist folder. I couldn’t figure out what happened, so I scratched a toy project to test things out.

Here is the gulp file that compiles the source

the sourceMaps.write('.') will add sourcemaps right next to the compiled files, you can also use sourceMaps.write() to generate inline sourcemaps.

But this didn’t work. Webstorm cannot find the breakpoints in source files. I didn’t know what to do, so I just randomly read documents of babel…

Trying to log errors with winston, here is how I created the logger

Very simple, it’s what the official document does. But the timestamp in the log file made no sense to me, since it’s ISO date.


I read the document, it gives no hint of how to customize the date format. So I did the old-fashioned way, read the source code. The file is located at node_modules/logform/timestamp.js

So it either takes a {format: string}, or {format: function}, when passed a string, the string is delegated to fecha to format the date string; or winston calls the function which should return a string. It also supports alias, let’s have fun!

Sorry about the order of the files, I don’t know how to sort the files in Gist.

I love to run expressjs with pm2, but how do I debug a pm2 managed process with Vscode?

As it turns out Vscode as a debug option call “Attach” which allows you to attach to a running nodejs program. All you need to do is add the configuration:

"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229

Then you can start your pm2 with the following command

$ pm2 start "My App" --node-args="--inspect-brk" --watch

Done! Now hit the debug button, and you can happily debugging your code.

I downloaded the starter kit from http://start.spring.io/, unzipped it, then ran the command ./mvnw spring-boot:run. It ran smooth for a while until this happend:

Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I was confused. As a newbie of both Java and Spring, I just lost. So I did what a programmer would do under such circumstance: Google it.

It was fruitless for a while. Either I didn’t understand the answer, or the answer was irrelevant I couldn’t tell. But I figured out it had something to do with Java version. So I searched Spring boot Java 9. Bang, there is a wiki for…

Earlier this morning I was trying to fix some data in my Redis database, I renamed one key to another with the RENAME command, without realizing the key I renamed to already existed. So what happened? Here is the doc:

If newkey already exists it is overwritten, when this happens RENAME executes an implicit DEL operation,

When you execute RENAME key1 key2, the data in key2 will be deleted, and unless you have dumped the data, there is no way to get your data back. That’s how I lost my data. Right now I am crawling the etherscan.io page to get them back, it might take me an entire afternoon.

The merit of my story, backup you key before you use RENAME.

Chris Peng

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store