<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I was made some experiments with heart <br></div>and I found something surpizing, athough it<br></div>does the job.<br><br></div>I start a erlang vm in daemon mode under user called<br></div>_user0 with home in /var/app like this <br>(from a shell script /var/app/appd run with sudo as a priv user):<br><br>case $1 in<br>  start)<br><br>su - _user0 -c "$ERL -boot start_sasl -config $LOG +K true +A 4 -sname $NODE  -heart -detached -s app_ctl start $NODE"<br><div><div><div><div><div><div><br>;;<br>  <br>  restart)<br>     /usr/local/lib/erlang/lib/erl_interface-3.7.20/bin/erl_call -q -sname $NODE<br>     sleep 2<br>     $ERL -boot start_sasl -config $LOG +K true +A 4 -sname $NODE\<br>                                 -heart -detached -s app_ctl start $NODE<br>    ;;<br><br>....<br><br></div><div>exit 0<br><br></div><div>environment vars are(under user _user0): <br><br>HEART_COMMAND=/bin/sh /var/app/appd  restart<br>ERL_CRASH_DUMP_SECONDS=10<br><br></div><div>I have noticed 3 problems:<br></div><div>1)  Starting the daemon (as a priv user) with sudo sh /var/app/appd start<br></div><div>     it starts the heart subsystem, but when I issue sudo kill -9 <pid-of_erlang- <br>    vm-monitored-byheart>, the erlang vm is killed but heart never restarts it;<br></div><div>    Running as _user0 the command /bin/sh /var/app/appd  restart manually<br></div><div>    heart restarts the system monitored after was killed;<br><br></div><div>2) Everytime I kill a vm monitored by heart with kill -9 <pid-of-vm> the heart procces restarts it immediately, and after that the heart process dies itself,and if in restart is not mentioned -heart option, the heart process is not restarted for the newly restarted erlang vm.<br><br></div><div>3) It seems the default timeout of 60 seconds is not respected because<br></div><div>the vm is restarted immediately  -heart option is specified in restart script;<br></div><div><br></div><div>So a heart process is tied up to an erlang vm that it monitors and it dies after it spawns another erlang vm?<br><br></div><div>The docs are not clear about these.<br><br></div><div>Having said these what are the best practices to use heart and why <br></div><div>heart behaves like above?<br><br></div><div>It seems heart works with kill -KILL|SIGV <pid-of-vm>, but I  am not sure<br></div><div>what happens if the erlang vm crashes when runs out of memory of file descriptors.<br></div><div>Is the vm restarted by heart in these conditions?<br></div><div><br></div><div>System: OTP 17.5 64 bits<br><br></div><div>Thanks,<br></div><div>Bogdan<br></div><div><br></div></div></div></div></div></div></div>