3.17.1 on Centos 7
hhvm -m daemon -u nginx -c /etc/hhvm/server.ini
_Unable to open pid file /run/hhvm.pid for write_
I know this is not a fatal error, but when I run the hhvm daemon, the following error saved in error.log:
Unable to open pid file /run/hhvm.pid for write
My server.ini looks like this
Does the nginx user have permissions to write to the /run directory?
HHVM typically puts the pid file in /var/run/hhvm/hhvm.pid The/run (or /var/run they are symlinked) directory is actually a mounted tmpfs filesystem (on most linux distros), and will not survive a reboot. This means it is typically the job of an init.d script to setup the appropriate skeleton directories and permissions. In the case of our distributed packages, this happens here: https://github.com/hhvm/packaging/blob/master/hhvm/deb/skeleton/etc/init.d/hhvm#L57
@jazzdan No! nginx user doesn't have permissions to write to the /run directory.
I use below service file to start and stop hhvm daemon. So, is that above mentioned error important? And should I fix it?
[Unit]
Description=HipHop Virtual Machine
[Service]
PIDFile=/run/hhvm.pid
ExecStart=/usr/local/bin/hhvm -m daemon -u nginx -c /etc/hhvm/server.ini
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
@ahmadazimi you should fix it. I would create the /var/run/hhvm directory and give the nginx user permissions to write to that directory. You could do this as a component of your service file, or as part of your configuration management system that installs HHVM.
In your systemd unit add:
RuntimeDirectory=hhvm
User=nginx
Remove the -u nginx from the ExecStart string.
Switch the pid file to be /var/run/hhvm/hhvm.pid for both the unit, and the hhvm config.
I haven't tested this, but it should work for getting the PID file setup with proper permissions.
This is not an issue with HHVM, so I am closing this issue.
@mofarrell & @jazzdan Thanks for great help.
Now hhvm starts without any errors.
My final hhvm.service (to help others, if they come here):
[Unit]
Description=HipHop Virtual Machine
[Service]
PIDFile=/run/hhvm/hhvm.pid
ExecStart=/usr/local/bin/hhvm -m daemon -c /etc/hhvm/server.ini
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
RuntimeDirectory=hhvm
User=nginx
[Install]
WantedBy=multi-user.target