Rozul Imam
IT Web Programmer

Instalasi Supervisor pada SUSE Linux Enterprise Server (SLES) 15 SP2

Supervisor adalah tool proses manajemen yang dirancang untuk membantu menjalankan dan mengawasi aplikasi di sistem UNIX atau Linux. Supervisor memungkinkan pengguna untuk memulai, menghentikan, dan mengawasi berbagai proses secara otomatis sehingga aplikasi yang berjalan di background dapat tetap hidup meskipun ada kegagalan. Tool ini sangat bermanfaat untuk menjalankan aplikasi server yang membutuhkan uptime tinggi karena Supervisor akan otomatis me-restart proses jika mendeteksi adanya kegagalan.

Envirotment:

NAME="SLES"
VERSION="15-SP2"
VERSION_ID="15.2"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP2"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:15:sp2"	

Jalankan perintah zypper search supervisor untuk memastikan apakah repo supervisor tersedia atau tidak.

Loading repository data...
Reading installed packages...
No matching items found.

Jika tidak ditemukan silahkan ketik yes

For an extended search including not yet activated remote resources you may run 'zypper
search-packages' at any time.
Do you want to run 'zypper search-packages' now? [yes/no/always/never] (no): yes

Jika muncul pesan seperti ini, kemungkinan besar OS belum berlisensi/aktivasi

Following packages were found in following modules:

Package     Module or Repository                       SUSEConnect Activation Command              
----------  -----------------------------------------  --------------------------------------------
supervisor  SUSE Package Hub (PackageHub/15.2/x86_64)  SUSEConnect --product PackageHub/15.2/x86_64

To activate the respective module or product, use SUSEConnect --product.
Use SUSEConnect --help for more details.

Jika sudah berlisensi/aktivasi ulangi perintah zypper search supervisor untuk memastikan bahwa repo supervisor sudah tersedia

zypper search supervisor
Refreshing service 'Basesystem_Module_15_SP2_x86_64'.
Refreshing service 'Containers_Module_15_SP2_x86_64'.
Refreshing service 'Desktop_Applications_Module_15_SP2_x86_64'.
Refreshing service 'Development_Tools_Module_15_SP2_x86_64'.
Refreshing service 'SUSE_Linux_Enterprise_Server_15_SP2_x86_64'.
Refreshing service 'SUSE_Package_Hub_15_SP2_x86_64'.
Refreshing service 'Server_Applications_Module_15_SP2_x86_64'.
Refreshing service 'Web_and_Scripting_Module_15_SP2_x86_64'.
Loading repository data...
Warning: Repository 'Backports SLE-15-SP2 (standard)' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...

S | Name       | Summary                                           | Type
--+------------+---------------------------------------------------+-----------
  | supervisor | A system for controlling process state under UNIX | package
  | supervisor | A system for controlling process state under UNIX | srcpackage


For an extended search including not yet activated remote resources you may run 'zypper
search-packages' at any time.
Do you want to run 'zypper search-packages' now? [yes/no/always/never] (no): no

Jalankan perintah zypper install supervisor untuk memulai instalasi

zypper install supervisor
Refreshing service 'Basesystem_Module_15_SP2_x86_64'.
Refreshing service 'SUSE_Linux_Enterprise_Server_15_SP2_x86_64'.
Refreshing service 'SUSE_Package_Hub_15_SP2_x86_64'.
Refreshing service 'Server_Applications_Module_15_SP2_x86_64'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  supervisor

The following package has no support information from its vendor:
  supervisor

1 new package to install.
Overall download size: 558.0 KiB. Already cached: 0 B. After the operation, additional 3.8 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y

Pastikan supervisor sudah tersintal dengan perintah pip3 show supervisor

Name: supervisor
Version: 4.1.0
Summary: A system for controlling process state under UNIX
Home-page: http://supervisord.org/
Author: Chris McDonough
Author-email: chrism@plope.com
License: BSD-derived (http://www.repoze.org/LICENSE.txt)
Location: /usr/lib/python3.6/site-packages
Requires: 
Required-by:  

Kemudian menuju ke folder /etc, cek apakah sudah tersedia file supervisord.conf atau belum, jika tidak ada maka kita buat file konfigurasi supervisor

Buat konfigurasi superuser dengan perintah berikut

echo_supervisord_conf > supervisord.conf

Selanjutnya edit file konfigurasi

vi supervisord.conf

Menuju ke halaman paling bawah tambahkan kode berikut

[program:todo] 
command=/usr/bin/php /srv/www/htdocs/todo/artisan queue:work --sleep=5 --tries=5
autostart=true
autorestart=true
user=wwwrun
numprocs=1
stderr_logfile=/var/log/supervisord/todo.err.log
stdout_logfile=/var/log/supervisord/todo.out.log

Kemudian simpan file dan jalankan supervisor dengan perintah berikut

supervisord -c supervisord.conf

Setelah Supervisor berjalan, Anda bisa mengelola proses menggunakan supervisorctl. Misalnya, untuk melihat status proses:

supervisorctl -c supervisord.conf status

Jika muncul seperti ini maka sudah berhasil dijalankan

todo RUNNING   pid 14440, uptime 0:01:07

Untuk memulai, menghentikan, atau me-restart program, gunakan perintah berikut:

supervisorctl -c supervisord.conf start todo
supervisorctl -c supervisord.conf stop todo
supervisorctl -c supervisord.conf restart todo

Jika ada perubahan konfigurasi maka jalankan perintah ini

supervisorctl reread
sudo supervisorctl update