HHVM upstart script

@mattylb we already added this script to our hhvm checklist - https://github.com/rtCamp/easyengine/issues/199 :slight_smile:

1 Like

We can also use ps-watcher for monitoring HHVM (or other processes) and start it automatically. Just saying…

$ apt-get install ps-watcher

Edit /etc/ps-watcher.conf (you might have to create it) and add the following lines:

[hhvm]
occurs = none
action = service hhvm restart

Enable ps-watcher to start:

$ sed -i -e 's/# startup=1/startup=1/g' /etc/default/ps-watcher
3 Likes

@alexblajan ps-watcher is nice. Thanks for sharing. :slight_smile:

1 Like

When updates come in for HHVM, the update will re-create the start script in /etc/init.d. Maybe there is a better way than this, but I run the following after each HHVM update:

sudo service hhvm stop; sudo mv /etc/init.d/hhvm ~/unused/hhvm-init-d ; sudo service hhvm start

obviously you need to either create ~/unused or pick a place where you want to save off the packaged init script.

Can you break this part down for those new to server side command line:

How and where do you create “~/unused”

No offense intended, but if creating ~/unused (or some preferred alternative) is opaque to you, using EE, trying to run a server with HHVM, etc. is probably beyond your current skillset and you might want to back up a little bit and get some basic linux shell training.

That said,

HOW: you make a directory on the command line with the command mkdir

WHERE: is actually already in what I wrote because the ‘~’ is a shortcut in the linux shell for your home directory, so if you type mkdir ~/unused you will create a directory called “unused” inside your home directory.

(But you might not want to keep it there. You can put it (the start script) anywhere you want or even just throw it away [ rm /etc/init.d/hhvm]. The idea is just to get it out of /etc/init.d so it won’t be executed by the system automatically. Again, all of this is basic linux shell / sysadmin stuff that you really need to already know if you are trying to set up and maintain a server with EE).

Thanks for the breakdown, yes I am in the process of learning and this has helped me, and I’m sure it would help others who land on it as well.

I found another good one: monit. it seems its running in the background, daemon, and watches over HHVM. if it uses to much ram/cpu or goes down, it restarts/runs HHVM. See what’s better for EE

1 Like

I’m trying monit and followed these directions to make a file to watch HHVM: https://codeable.io/community/speed-up-wp-admin-redis-hhvm/

check process hhvm with pidfile /var/run/hhvm/pid
group hhvm
start program = "/usr/sbin/service hhvm start" with timeout 60 seconds
stop program  = "/usr/sbin/service hhvm stop"
if failed unixsocket /var/run/hhvm/hhvm.sock then restart
if mem > 400.0 MB for 1 cycles then restart
if 5 restarts with 5 cycles then timeout

But the odd thing is when my HHVM crashes it’s not only a HHVM restart that’s required but I found running ee stack restart and ee clean gets it working again. I’m not familiar with monit, but is there a way it or something else can automatically flush FastCGI and restart the ee stack in addition to restarting hhvm when hhvm crashes?

2 Likes

I really don’t know. I’m using the script from pjv

monit is awesome

1 Like

Yes it is :slight_smile:

Hi,

Did you use Monit successfully? Would be great if you can share your experience.

Cheers, Tony

Hey @JDdiego, did you find a solution to this?

I’m also interested in this, but have a hard time figuring out what is actually needed. Do we need to alter this code?

// Jens.

@alexblajan

Did you find a solution to get monit to work? I saw that you had commented on the article (https://codeable.io/community/speed-up-wp-admin-redis-hhvm/), and wanted to ask if this solution worked for you?

Hey ! Yes that solution worked fine for me. I forgot to update you on this !
I used the config from rtCamp.com/tutorials and for monitoring setting I used the one from codeable.

Great! Thanks @alexblajan! So you didn’t have to do anything about the socket / ip issue, you could just use the code as is?

Really appreciate your help!

// Jens.

No. rtCamp didn’t put how to monitor HHVM and because HHVM doesn’t use the sock, you need to use the following line:

"if failed host localhost port 9000 then restart"

Hi @pjv

Please try the latest EasyEngine. Use ee update to upgrade your current EasyEngine version to the latest.

It’s been a long time, and we haven’t heard from you. It looks like your issue is resolved.

I am closing this support topic for now. Feel free to create a new support topic if you have any queries further. :slight_smile: