Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service: Php Fastcgi #14

Closed
simbora opened this issue Aug 19, 2014 · 5 comments
Closed

Service: Php Fastcgi #14

simbora opened this issue Aug 19, 2014 · 5 comments

Comments

@simbora
Copy link
Owner

simbora commented Aug 19, 2014

Depends on Php and Fastcgi.

Create /etc/init/php-fastcgi.conf with:

description "PHP Fastcgi daemon"


start on (local-filesystems and net-device-up)
stop on runlevel [!2345]

respawn

exec /usr/bin/spawn-fcgi \
    -n \
    -a 127.0.0.1 \
    -p 9000 \
    -C 6 \
    -u deploy \
    -g deploy \
    -f /usr/bin/php5-cgi

Run:

start php-fastcgi
@simbora simbora changed the title Module: Php Fastcgi Service: Php Fastcgi Aug 19, 2014
@rxaviers rxaviers added this to the Services deployment milestone Aug 19, 2014
@rxaviers
Copy link
Collaborator

rxaviers commented Oct 6, 2014

I've updated description and replaced the init.d scripts with upstart equivalent.

     chmod +x /usr/local/bin/php-fastcgi

-Create `/etc/init.d/php-fastcgi` with:
+Create `/etc/init/php-fastcgi.conf` with:

-    #!/bin/bash
+    description "PHP Fastcgi daemon"

-    PHP_SCRIPT=/usr/local/bin/php-fastcgi
-    FASTCGI_USER=deploy
-    FASTCGI_GROUP=deploy
-    PID_DIR=/var/run/php-fastcgi
-    PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid
-    RET_VAL=0
+    start on (local-filesystems and net-device-up)
+    stop on runlevel [!2345]
+
+    expect daemon
+    respawn

-    case "$1" in
-        start)
-          if [[ ! -d $PID_DIR ]]
-          then
-            mkdir $PID_DIR
-            chown $FASTCGI_USER:$FASTCGI_GROUP $PID_DIR
-            chmod 0770 $PID_DIR
-          fi
-          if [[ -r $PID_FILE ]]
-          then
-            echo "php-fastcgi already running with PID `cat $PID_FILE`"
-            RET_VAL=1
-          else
-            $PHP_SCRIPT
-            RET_VAL=$?
-          fi
-      ;;
-        stop)
-          if [[ -r $PID_FILE ]]
-          then
-            kill `cat $PID_FILE`
-            rm $PID_FILE
-            RET_VAL=$?
-          else
-            echo "Could not find PID file $PID_FILE"
-            RET_VAL=1
-          fi
-      ;;
-        restart)
-          if [[ -r $PID_FILE ]]
-          then
-            kill `cat $PID_FILE`
-            rm $PID_FILE
-            RET_VAL=$?
-          else
-            echo "Could not find PID file $PID_FILE"
-          fi
-          $PHP_SCRIPT
-          RET_VAL=$?
-      ;;
-        status)
-          if [[ -r $PID_FILE ]]
-          then
-            echo "php-fastcgi running with PID `cat $PID_FILE`"
-            RET_VAL=$?
-          else
-            echo "Could not find PID file $PID_FILE, php-fastcgi does not appear
-to be running"
-          fi
-      ;;
-        *)
-          echo "Usage: php-fastcgi {start|stop|restart|status}"
-          RET_VAL=1
-      ;;
-    esac
-    exit $RET_VAL
+    exec /usr/local/bin/php-fastcgi

 Run:

-    chmod +x /etc/init.d/php-fastcgi
-    update-rc.d php-fastcgi defaults
-    service php-fastcgi start
+    start php-fastcgi

@dzydzany
Copy link
Collaborator

Branch is created from issue-12 and issue-13 branch

@dzydzany
Copy link
Collaborator

Changed PID folder to /var/run as /var/run/php-fastcgi dissapears on reboot.

@rxaviers
Copy link
Collaborator

Branch is created from issue-12 and issue-13 branch

No problem.

@rxaviers
Copy link
Collaborator

I've updated the description with:

Create /etc/init/php-fastcgi.conf with:

description "PHP Fastcgi daemon"


start on (local-filesystems and net-device-up)
stop on runlevel [!2345]

respawn

exec /usr/bin/spawn-fcgi \
    -n \
    -a 127.0.0.1 \
    -p 9000 \
    -C 6 \
    -u deploy \
    -g deploy \
    -f /usr/bin/php5-cgi

The previous expect daemon way was wrong (start/stop was getting locked).

rxaviers added a commit that referenced this issue Mar 29, 2015
dzydzany added a commit that referenced this issue Apr 8, 2015
rxaviers added a commit that referenced this issue Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants