]> git.pld-linux.org Git - packages/hhvm.git/commitdiff
add -fcgi package containing initscript to start as fcgi server
authorElan Ruusamäe <glen@delfi.ee>
Fri, 3 Jan 2014 12:41:52 +0000 (12:41 +0000)
committerElan Ruusamäe <glen@delfi.ee>
Fri, 3 Jan 2014 12:41:52 +0000 (12:41 +0000)
hhvm-fcgi.init [new file with mode: 0755]
hhvm-fcgi.sysconfig [new file with mode: 0644]
hhvm.spec

diff --git a/hhvm-fcgi.init b/hhvm-fcgi.init
new file mode 100755 (executable)
index 0000000..ca1de3d
--- /dev/null
@@ -0,0 +1,157 @@
+#!/bin/sh
+#
+# hhvm-fcgi -- startup script for HHVM FastCGI
+#
+# chkconfig:   345 80 20
+#
+# description:  Starts The HHVM FastCGI Daemon
+# processname: hhvm-fcgi
+# config:      /etc/hhvm/server.hdf
+# pidfile:     /var/run/hhvm/hhvm-fcgi.pid
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "HHVM FastCGI Daemon"
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+# Set defaults
+# Default values. This values can be overwritten in '/etc/sysconfig/hhvm-fcgi'
+DAEMON="/usr/bin/hhvm"
+NAME="hhvm"
+CONFIG_FILE="/etc/hhvm/server.hdf"
+RUN_AS_USER="http"
+LISTEN_PORT="9000"
+ADDITIONAL_ARGS=""
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/hhvm-fcgi ] && . /etc/sysconfig/hhvm-fcgi
+
+PIDFILE="/var/run/hhvm/hhvm-fcgi.pid"
+DAEMON_ARGS="--config ${CONFIG_FILE} \
+--user ${RUN_AS_USER} \
+--mode daemon \
+-vServer.Type=fastcgi \
+-vServer.Port=${LISTEN_PORT} \
+-vPidFile=${PIDFILE} \
+${ADDITIONAL_ARGS}"
+
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
+       start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test
+}
+
+# wrapper for configtest
+checkconfig() {
+       local details=${1:-0}
+
+       if [ $details = 1 ]; then
+               # run config test and display report (status action)
+               show "Checking %s configuration" "HHVM FastCGI Daemon"; busy
+               local out
+               out=$(configtest 2>&1)
+               RETVAL=$?
+               if [ $RETVAL = 0 ]; then
+                       ok
+               else
+                       fail
+               fi
+               [ "$out" ] && echo >&2 "$out"
+       else
+               # run config test and abort with nice message if failed
+               # (for actions checking status before action).
+               configtest >/dev/null 2>&1
+               RETVAL=$?
+               if [ $RETVAL != 0 ]; then
+                       show "Checking %s configuration" "HHVM FastCGI Daemon"; fail
+                       nls 'Configuration test failed. See details with %s "checkconfig"' $0
+                       exit $RETVAL
+               fi
+       fi
+}
+
+start() {
+       # Check if the service is already running?
+       if [ -f /var/lock/subsys/hhvm-fcgi ]; then
+               msg_already_running "HHVM FastCGI Daemon"
+               return
+       fi
+
+       checkconfig
+       msg_starting "HHVM FastCGI Daemon"
+       daemon --pidfile $PIDFILE $DAEMON $DAEMON_ARGS
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hhvm-fcgi
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/hhvm-fcgi ]; then
+               msg_not_running "HHVM FastCGI Daemon"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "HHVM FastCGI Daemon"
+       killproc --pidfile $PIDFILE $NAME -TERM
+       RETVAL=$?
+       rm -f /var/lock/subsys/hhvm-fcgi
+}
+
+condrestart() {
+       if [ ! -f /var/lock/subsys/hhvm-fcgi ]; then
+               msg_not_running "HHVM FastCGI Daemon"
+               RETVAL=$1
+               return
+       fi
+
+       checkconfig
+       stop
+       start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       checkconfig
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  checkconfig|configtest)
+       checkconfig 1
+       ;;
+  status)
+       status --pidfile $PIDFILE hhvm-fcgi hhvm
+       RETVAL=$?
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"
+       exit 3
+esac
+
+exit $RETVAL
diff --git a/hhvm-fcgi.sysconfig b/hhvm-fcgi.sysconfig
new file mode 100644 (file)
index 0000000..9b4f829
--- /dev/null
@@ -0,0 +1,33 @@
+## This is a configuration file for /etc/init.d/hhvm-fastcgi.
+## Overwrite start up configuration of the hhvm-fastcgi service.
+##
+## This file is sourced by /bin/sh from /etc/init.d/hhvm-fastcgi.
+
+## Configuration file location.
+## Default: "/etc/hhvm/server.hdf"
+## Examples:
+##   "/etc/hhvm/conf.d/fastcgi.hdf" Load configuration file from Debian/Ubuntu conf.d style location
+#CONFIG_FILE="/etc/hhvm/server.hdf"
+
+## User to run the service as.
+## Default: "http"
+## Examples:
+##   "hhvm"   Custom 'hhvm' user
+##   "nobody" RHEL/CentOS 'www-data' equivalent
+#RUN_AS_USER="http"
+
+## Listen port of service.
+## This is useful if the port is used by an other service like PHP-FPM.
+## Default: "9000"
+#LISTEN_PORT="9000"
+
+## Add additional arguments to the hhvm service start up.
+## Default: ""
+## Examples:
+##   "-vLog.Level=Debug"                Enable debug log level
+##   "-vServer.DefaultDocument=app.php" Change the default document
+#ADDITIONAL_ARGS=""
+
+## PID file location.
+## Default: "/var/run/hhvm/hhvm-fcgi.pid"
+#PIDFILE="/var/run/hhvm/hhvm-fcgi.pid
index 78d938c56c5efe2d958c96b3726c85326959d8e5..32254cc45425c747954e457b9b906ed3d265d3d2 100644 (file)
--- a/hhvm.spec
+++ b/hhvm.spec
@@ -7,7 +7,7 @@
 Summary:       Virtual Machine, Runtime, and JIT for PHP
 Name:          hhvm
 Version:       2.3.2
-Release:       0.8
+Release:       0.19
 License:       PHP 3.01
 Group:         Development/Languages
 Source0:       https://github.com/facebook/hhvm/archive/HHVM-%{version}.tar.gz
@@ -17,6 +17,8 @@ Source1:      http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
 # Source1-md5: a00e037e4d3f9e4fe9893e8a2d27918c
 Source2:       https://github.com/facebook/folly/archive/4d6d659/folly-0.1-4d6d659.tar.gz
 # Source2-md5: 2e7c941f737c8e0a449b8116e7615656
+Source3:       %{name}-fcgi.init
+Source4:       %{name}-fcgi.sysconfig
 Source100:     get-source.sh
 Patch0:                cmake-missing-library.patch
 Patch1:                libevent14.patch
@@ -138,6 +140,17 @@ webserver and the "mod_php" extension). HHVM can also be used together
 with a FastCGI-based webserver, and work is in progress to make HHVM
 work smoothly with Apache.
 
+%package fcgi
+Summary:       Init script to start HHVM as FastCGI daemon
+Group:         Development/Languages/PHP
+Requires:      %{name} = %{version}-%{release}
+Provides:      php(fcgi)
+Requires(post,preun):  /sbin/chkconfig
+Requires:      rc-scripts
+
+%description fcgi
+Init script to start HHVM as FastCGI daemon
+
 %package program
 Summary:       /usr/bin/php symlink
 Summary(pl.UTF-8):     Dowiązanie symboliczne /usr/bin/php
@@ -261,6 +274,11 @@ ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/hphp
 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf
 cp -p hphp/doc/mime.hdf $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf/static.mime-types.hdf
 
+# install fastcgi initscript
+install -d $RPM_BUILD_ROOT/etc/{sysconfig,rc.d/init.d}
+cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-fcgi
+cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/%{name}-fcgi
+
 # install our libevent for now
 install -d $RPM_BUILD_ROOT%{_libdir}
 libtool --mode=install install -p libevent/libevent.la $RPM_BUILD_ROOT%{_libdir}
@@ -308,6 +326,16 @@ rm -rf $RPM_BUILD_ROOT
 %post  -p /sbin/ldconfig
 %postun        -p /sbin/ldconfig
 
+%post fcgi
+/sbin/chkconfig --add %{name}-fcgi
+%service %{name}-fcgi restart
+
+%preun fcgi
+if [ "$1" = "0" ]; then
+       %service -q %{name}-fcgi stop
+       /sbin/chkconfig --del %{name}-fcgi
+fi
+
 %files
 %defattr(644,root,root,755)
 %doc README.md hphp/NEWS
@@ -320,6 +348,11 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_datadir}/%{name}/hdf
 %{_datadir}/%{name}/hdf/static.mime-types.hdf
 
+%files fcgi
+%defattr(644,root,root,755)
+%attr(754,root,root) /etc/rc.d/init.d/%{name}-fcgi
+%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}-fcgi
+
 %files program
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_bindir}/php
This page took 0.091448 seconds and 4 git commands to generate.