This post was originally published on this site

If you would like to create your own MapR Service under the control of warden here’s an example based on a haproxy configuration how to achieve this.

The method should work for any other service as well

create new role

$ touch /opt/mapr/roles/haproxy

 

create new warden service configuration

$ vi /opt/mapr/conf/conf.d/warden.haproxy.conf

services=haproxy:all:cldb
service.displayname=haproxy
service.command.start=/home/mapr/start_haproxy.sh
service.command.stop=/home/mapr/stop_haproxy.sh
service.command.type=BACKGROUND
service.command.monitorcommand=/home/mapr/status_haproxy.sh
service.port=9999
service.uri=about
service.logs.location=/var/log/haproxy/
service.process.type=BINARY

 

save the file and check the permissions (should be 644)

$ pwd
/opt/mapr/conf/conf.d

$ ls -la warden.haproxy.conf
-rw-r--r-- 1 mapr mapr 398 Oct 4 14:21 warden.haproxy.conf

 

create the scripts referenced in /opt/mapr/conf/conf.d/warden.haproxy.conf

$ pwd
/home/mapr/scripts

$ cat stop_haproxy.sh
#stop haproxy
sudo systemctl stop haproxy

$ cat start_haproxy.sh
#start haproxy
sudo systemctl start haproxy

$ cat status_haproxy.sh
#status haproxy
sudo systemctl status haproxy

reconfigure MapR System

$ /opt/mapr/server/configure.sh -R

If the configuration was successful the newly created haproxy service should be visible in MapR Control System and also via command line

$ maprcli service list -node $(hostname)

logpath             displayname name      memallocated  state

[...]

/var/log/haproxy/   haproxy     haproxy   Auto          2

[...]

Now you should also be able to start and stop the haproxy with maprcli commands.

 

$ maprcli node services -action start haproxy -nodes <node-name>

$ maprcli node services -action stop haproxy -nodes <node-name>

 

 

The post Integrate haproxy service in MapR Control System appeared first on blog.muehlbeyer.net.