browse by category or date

Reviewing the logs of this website, is one of my weekly activities. Most of the time, I only need to clear the logs to save space. But today, I notice there’s something wrong with this post. The log indicates that NGINX is unable to reach the internal gateway (the Go application).

Well this is weird. I remember I already set the program as a background service. To ensure that this is the case, I checked if the service is already created in systemd:

sudo nano /lib/systemd/system/golisj.service

The file exists, and it has content:

[Unit]
Description=Golang Lisajeous Image Process Manager
Documentation=
Requires=nginx.service
After=nginx.service

[Service]
Type=simple
PIDFile=/run/golang/golisj.pid
ExecStart=-/root/go/src/server/server
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Check Service Status

service golisj status

Output:

● golisj.service – Golang Lisajeous Image Process Manager
Loaded: loaded (/lib/systemd/system/golisj.service; disabled; vendor preset: enabled)
Active: inactive (dead)

Start Service

sudo service golisj start

Now we check the status

sudo service golisj status

Output:

Enable Service

To make sure the service is running after reboot, we need to enable the service

sudo systemctl enable golisj

Output:

Created symlink /etc/systemd/system/multi-user.target.wants/golisj.service → /lib/systemd/system/golisj.service.

Check the status again:

sudo service golisj status

Output:

To test it out, I rebooted the server. When I opened the post, I can see the animated gifs running. I Ctrl+F5 one more, the gifs is still there. That means the service is now running after restart.

I hope it helps. Cheers!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

What is Factors?

If we multiply two numbers, it gives a product. The two numbers are the factors of the product.

For example:

5 x 2 = 10

So 2 and 5 is the factors of 10

To practice to find the factors of big numbers, you can use the circles below. First, you need to enter a number in the green circle. This number is the number which you want to find its factors.

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

For most of us, Date formatting in JavaScript is handled by external library/plugin (jQuery’s dateFormat, jQuery-UI’s datepicker). But if somehow your project has no access to them, you can extend Date by yourself.

window.Date.prototype.format = function(fmt){
	if (!fmt) return this.toString();
	
	var rgx = /[a-zA-Z]+/g;
	if (fmt.replaceAll) {
		var year = this.getFullYear().toString();
		var month = this.getMonth();
		var date = this.getDate();            
		var arMonths = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN",
			"JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
		var that = this;
		fmt = fmt.replaceAll(rgx, function (f) {
			switch (f) {
				case "yyyy": return year;
				case "yy": return year.substr(2);
				case "MMM": return arMonths[month];
				case "dd": return date.toString().padStart(2, "0"); 
			}
			return f;
		});
	}
	return fmt;
}

Now you can the new format function in the Date class

As shown above, if format function is unable to handle the format string specified, it will just returns the original text. What you need to do now is to add the new case inside switch(f){ …. }. For example, we want to handle HH format.

			switch (f) {
				// ... SNIP ...
				case "HH": return that.getHours().toString().padStart(2, "0");
			}

Now, we should see the correct value.

I hope it helps. Cheers!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: