Beberapa waktu lalu, saya melakukan upgrade software nginx pada salah satu server namun ketika direstart sangat lama sekali dengan pesan kurang lebih seperti ini:
# service nginx status ● nginx.service - nginx - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: timeout) since Sun 2020-02-23 21:45:15 WIB; 2min 11s ago Docs: http://nginx.org/en/docs/ Process: 272 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Feb 23 21:43:45 twice systemd[1]: Starting nginx - high performance web server... Feb 23 21:43:45 twice systemd[1]: nginx.service: Can't open PID file /var/run/nginx.pid (yet?) after start: Too many levels of symbolic links Feb 23 21:45:15 twice systemd[1]: nginx.service: Start operation timed out. Terminating. Feb 23 21:45:15 twice systemd[1]: Failed to start nginx - high performance web server. Feb 23 21:45:15 twice systemd[1]: nginx.service: Unit entered failed state. Feb 23 21:45:15 twice systemd[1]: nginx.service: Failed with result 'timeout'.
Ini yang jadi masalah kayanya folder /var/run/ jadi saya coba cek isinya, kurang lebih seperti ini:
# ls -lrth total 36K drwxr-xr-x 2 root root 40 Dec 30 13:34 rpc_pipefs drwxr-xr-x 2 root root 60 Dec 30 13:34 mount drwxr-xr-x 3 root root 60 Dec 30 13:34 log drwxrwxrwt 2 root root 40 Dec 30 13:34 shm drwxr-xr-x 2 root root 60 Dec 30 13:34 sysconfig drwxr-xr-x 2 root root 40 Dec 30 13:34 sendsigs.omit.d lrwxrwxrwx 1 root root 25 Dec 30 13:34 initctl -> /run/systemd/initctl/fifo drwxr-xr-x 2 root root 40 Dec 30 13:34 sshd drwxr-xr-x 2 root root 40 Dec 30 13:34 user drwxr-xr-x 2 root root 40 Dec 30 13:34 sudo drwxrwxrwt 3 root root 80 Dec 30 13:34 lock drwxr-xr-x 2 root root 140 Dec 30 13:34 network srw-rw-rw- 1 root root 0 Dec 30 13:34 rpcbind.sock drwxr-xr-x 2 root root 60 Dec 30 13:34 dbus -r--r--r-- 1 root root 0 Dec 30 13:34 rpcbind.lock -rw-r--r-- 1 root root 4 Dec 30 13:34 crond.pid ---------- 1 root root 0 Dec 30 13:34 crond.reboot -rw-r--r-- 1 root root 3 Dec 30 13:34 rsyslogd.pid drwxr-xr-x 4 root root 100 Dec 30 13:34 udev -rw-r--r-- 1 root root 4 Dec 30 13:34 monit.pid -rw-r--r-- 1 root root 4 Dec 30 13:34 sshd.pid -rw-r--r-- 1 root root 4 Dec 30 13:34 xinetd.pid -rw------- 1 root root 0 Dec 30 13:34 agetty.reload -rw-r----- 1 root root 0 Dec 31 06:55 unattended-upgrades.lock drwxr-xr-x 2 root root 80 Jan 17 14:35 rpcbind -rw-r--r-- 1 root root 0 Jan 17 14:36 init.upgraded -rw-r--r-- 1 root root 0 Jan 17 14:36 reboot-required drwxr-xr-x 3 root root 60 Jan 22 06:57 samba drwx--x--- 2 root sasl 140 Jan 29 06:53 saslauthd drwxr-xr-x 2 mysql root 80 Feb 4 09:00 mysqld -rw-r--r-- 1 root root 31 Feb 19 06:20 unattended-upgrades.progress -rw-r--r-- 1 root root 388 Feb 23 21:06 motd.dynamic -rw-rw-r-- 1 root root 1.9K Feb 23 21:06 utmp drwxr-xr-x 2 root root 60 Feb 23 21:15 php -rw-r--r-- 1 root root 0 Feb 23 21:17 hello.txt drwxr-xr-x 17 root root 440 Feb 23 21:30 systemd -rw-r--r-- 1 root root 5 Feb 23 21:33 nginx.pid
Ini saya coba cek lagi ternyata eh ternyata, folder /var/run adalah symlink dari folder /run/ yang memang sengaja didesain ubuntu sedemikian rupa. Nah untuk memperbaikinya cukup mudah, cukup sesuaikan yang tadinya /var/run/nginx.pid menjadi /run/nginx.pid. Kurang lebih seperti ini:
Pada file /lib/systemd/system/nginx.service:
PIDFile=/run/nginx.pid
Pada file /etc/nginx/nginx.conf:
pid /run/nginx.pid;
Jalankan daemon-reload:
systemctl daemon-reload
Kemudian restart nginx:
systemctl restart nginx
Mestinya sukses jalan kembali si nginx yang tadi ga bisa jalan itu, hehe sip sip semoga bermanfaat ya~~