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
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
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!
loading...
About Hardono
Incoming Search
golang, linux, service, ubuntu