Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  A journey to investigate a goroutine leakage case

In Go, creating goroutines is straightforward, but improper usage may result in a large number of goroutines unable to terminate, leading to resource leakage and memory leaks over time. The key to avoiding goroutine leaks is to manage the lifecycle of goroutines properly. By exporting runtime metrics and utilizing pprof, one can detect and resolve goroutine leakage issues.This post will go through one real case encountered by the author. The author maintains a service that connects to a target machine via SSH and executes commands. This is an internal service that is usually not closely monito...

806 0       GOLANG PPROF GOROUTINE LEAK DEBUG GUIDE SSH TIMEOUT


  Use Delve to debug GoLang program

If you don't know how to debug program, you are not a real programmer.gdb can be used to debug go program, but according to golang website, delve is a better option. Note that Delve is a better alternative to GDB when debugging Go programs built with the standard toolchain. It understands the Go runtime, data structures, and expressions better than GDB.Below is a simple go program.package maintype Person struct { Name string Age int}func main() { var me Person me.Name = "Melvin" me.Age = 41 var wife Person wife.Name = "Raye" wife.Age = 36 var daughter Person daughter.Name = "Kat...

3,353 0       DELVE GOLANG DEBUG


  Using public key authentication in SSH

SSH is a popular cryptographic network protocol for secure network service operation. It is frequently used in remote server login. For a system administrator or software developer, SSH is frequently used to access remote servers or development servers or testing servers etc. To login with SSH, there are different authentication mechanisms : password, public key and interactive etc. If a remote server needs to be accessed frequently, password authentication may be too troublesome as password needs to be typed every time. In this scenario, public key authentication would be a life sav...

8,327 0       LINUX DEBUG SSH PUBLIC KEY


  What and what not to log while debugging

Log is a critical part of an application. It serves as an eye to the programmer on how the application is working while debugging. Especially for applications running on production environment, if the application encounters problem and the problem cannot be reproduced on other environments, log will be extremely useful.While log is essential, but developers have to log smartly. Because if don't put log smartly, you may not get what you want while debugging or you may get too many redundant logs which eat up the disk space and degrade the performance of the system.So what and wha...

5,194 0       PROGRAMMING SUPPORT DEBUG LOG


  PHP to output string to client terminal

It is a common task to echo messages to the user using PHP. There are lots of ways where the message can be echoed to the client terminal(browser or console window) through PHP. These includes some well know debug methods like var_dump() and var_export() etc. In this post, we will show you some other methods shared by Laruence, one of the core members of PHP development team.1. echoFirst comes with the most common one : echo.$str = "Hello PHP\n";echo $str;2. printThen comes another common one : print.$str = "Hello PHP\n";print $str;3. php://outputAlso we can use file_put_contents() t...

40,104 0       PHP TRICKS DEBUG OUTPUT


  Reproduce "MySQL server has gone away" in PHP

If you want to debug the issue of "MySQL server has gone away", you can reproduce it with below steps:Modify configuration file:sudo vi /etc/mysql/my.cnf  Make below changes:[mysqld]  wait_timeout = 30  interactive_timeout = 30  Restart the service:sudo /etc/init.d/mysql restart  Write below PHP codes:$link = mysql_connect('127.0.0.1', 'root', 'root');  if (!$link) {      die('Could not connect: ' . mysql_error());  ...

11,590 0       MYSQL DEBUG RMYSQL SERVER HAS GONE AWAY


  An easy way to log client side information to server

JavaScript debug is a very troublesome thing in web application development. Because many web browsers will not notify you if there is any error in the JavaScript codes you write. They just silently fail and block the following codes execution. In order to debug JavaScript codes, we need a good log mechanism which will help us log the error information,, we often need to log errors in JavaScript codes to server for debug purpose in a production web application,What should we do?The first thought comes into our mind may be using AJAX, since it involves client server communication and we al...

4,784 0       IMAGE DEBUG JAVASCRIPT LOG AJAX


  Use of log in programming

Usually, The purposes of log are for troubleshooting and displaying program running status. Good log will help us locate the error easier. Many programmers think log in programs is very simple, but it's not an easy task to write log codes to efficiently locate the error. Here we discuss about program log in three aspects:Where to logWhat to logLog styles to be avoidedWhere to log1. When calling external functionsWhen your program is calling some external functions which are not written by you, you need to log before and after the external function call. This will help debug.1. LOG.debug("Call...

3,568 0       PROGRAMMING DEBUG LOG