Skip to content

Instantly share code, notes, and snippets.

@yusukezzz
Last active January 26, 2017 12:25
Show Gist options
  • Save yusukezzz/9c0ae911ccb1378cb127 to your computer and use it in GitHub Desktop.
Save yusukezzz/9c0ae911ccb1378cb127 to your computer and use it in GitHub Desktop.
hhvm init.d script for centos
#!/bin/bash
#
# /etc/rc.d/init.d/hhvm
#
# Starts the hhvm daemon
#
# chkconfig: 345 26 74
# description: HHVM (aka the HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP
# processname: hhvm
### BEGIN INIT INFO
# Provides: hhvm
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop hhvm
# Description: HHVM (aka the HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
hhvm=/usr/bin/hhvm
prog=`/bin/basename $hhvm`
lockfile=/var/lock/subsys/hhvm
pidfile=/var/run/hhvm/pid
RETVAL=0
test -x /usr/bin/hhvm || exit 1
start() {
echo -n $"Starting $prog: "
daemon --pidfile ${pidfile} ${hhvm} --config /etc/hhvm/server.ini --mode daemon
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} ${prog}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
rh_status() {
status -p ${pidfile} ${hhvm}
}
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
reload|force-reload|restart|try-restart)
stop
start
;;
status)
rh_status
RETVAL=$?
;;
*)
echo "Usage: /etc/init.d/hhvm {start|stop|restart|status}"
exit 2
esac
exit $RETVAL
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format ltsv 'time:$time_local\t'
'host:$remote_addr\t'
'request:$request\t'
'status:$status\t'
'size:$body_bytes_sent\t'
'referer:$http_referer\t'
'ua:$http_user_agent\t'
'reqtime:$request_time\t'
'upsttime:$upstream_response_time';
access_log /var/log/nginx/access.log ltsv;
error_log /var/log/nginx/error.log;
# static file problem for virtualbox
sendfile off;
#tcp_nopush on;
keepalive_timeout 0;
#keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
charset utf-8;
root /vagrant_data/webapp/htdocs/public;
index index.php index.html;
error_page 404 /index.php;
location ~ \.(hh|php)$
{
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/hhvm/sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ /\.(ht|git|svn)
{
deny all;
}
location = /favicon.ico
{
access_log off;
log_not_found off;
}
location = /robots.txt
{
access_log off;
log_not_found off;
}
}
}
expose_php=Off
date.timezone = Asia/Tokyo
hhvm.pid_file = /var/run/hhvm/pid
hhvm.server.type = fastcgi
hhvm.server.file_socket = /var/run/hhvm/sock
hhvm.server.apc.enable_apc = true
hhvm.server.apc.table_type = concurrent
hhvm.server.apc.expire_on_sets = true
hhvm.server.apc.purge_frequency = 4096
hhvm.eval.jit = true
hhvm.eval.jit_warmup_requests=0
hhvm.log.level = Error
hhvm.log.file = /var/log/hhvm/error.log
hhvm.log.runtime_error_reporting_level = 8191
hhvm.log.use_log_file = true
hhvm.log.use_syslog = false
hhvm.log.access.*.file = /var/log/hhvm/access.log
hhvm.log.access.*.format = %h %l %u % t "%r" %>s %b
hhvm.repo.central.path = /var/log/hhvm/.hhvm.hhbc
hhvm.mysql.typed_results = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment