change the file argument, add support for pid_file, and change the way of wrting json