Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 265454 - www-servers/spawn-fcgi init script fails
Summary: www-servers/spawn-fcgi init script fails
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Thilo Bangert (RETIRED) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 264840
  Show dependency tree
 
Reported: 2009-04-08 14:23 UTC by Thilo Bangert (RETIRED) (RETIRED)
Modified: 2009-04-12 17:57 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
A patch fixing bad whitespaces + adding a check for FCGI_PROGRAM (spawn-fcgi-whitsespace-fix+bin-check.patch,957 bytes, patch)
2009-04-12 17:09 UTC, Elias Probst
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-04-08 14:23:04 UTC
from bug #149647 comment #42:
I copied /etc/conf.d/spawn-fcgi /etc/conf.d/spawn-fcgi.test and set:
FCGI_PROGRAM=/usr/bin/php-cgi
In spawn-fcgi.test

I symlinked /etc/init.d/spawn-fcgi to /etc/init.d/spawn-fgi.test

And yet when I try to start it I get:

 # /etc/init.d/spawn-fcgi.test start
 * Starting FastCGI application test ...
spawn-fcgi: child spawned successfully: PID: 10595        [ !! ]

I end up with no php-cgi processes running.

If I mod the init script slightly to echo the start-stop-daemon line and then
manually paste that into my shell, everything starts up fine. Which is odd,
because it's clearly not working from within the init script.

Any suggestions?
Comment 1 Gary Richards 2009-04-08 14:51:50 UTC
Portage 2.1.6.7 (default/linux/amd64/2008.0, gcc-4.3.3, glibc-2.8_p20080602-r1, 2.6.27-gentoo-r8 x86_64)
=================================================================
System uname: Linux-2.6.27-gentoo-r8-x86_64-QEMU_Virtual_CPU_version_0.9.1-with-glibc2.2.5
Timestamp of tree: Tue, 07 Apr 2009 08:45:01 +0000
app-shells/bash:     3.2_p39
dev-lang/python:     2.5.2-r7
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.63
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo.virginmedia.com http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LDFLAGS="-Wl,-O1"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cups dri fortran gdbm gpm iconv ipv6 isdnlog midi mmx mudflap multilib ncurses nls nptl nptlonly openmp pam pcre perl pppd python readline reflection session spl sse sse2 ssl sysfs tcpd unicode vhosts xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 intel mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 2 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-04-09 19:53:41 UTC
i believe to have fixed this in cvs. please give it a good round of testing...
you will have to remerge spawn-fcgi. (make sure your /etc/init.d/spawn-fcgi file has the following cvs signature: 
# $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.6 2009/04/09 19:48:39 bangert Exp $

thanks
Comment 3 James Le Cuirot gentoo-dev 2009-04-09 20:09:02 UTC
Ah so it was the PID directory! I did wonder whether you might have used dodir instead of keepdir. I didn't check that specifically but instead checked whether /var/run/spawn-fcgi was present in CONTENTS and it was. I guess that file gets written *before* Portage removes empty directories.
Comment 4 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-04-09 20:33:42 UTC
no - it was not the pid dir. this bug only happened on the stable baselayout, which uses a start-stop-daemon from debian. openrc has a rewritten start-stop-daemon and it is a little different.

debians start-stop-daemon would check if there was a program called spawn-fcgi running - since spawn-fcgi would spawn php, this would not be the case and it would fail. the openrc start-stop-daemon didnt care since the pid file was created correctly (i believe).
Comment 5 James Le Cuirot gentoo-dev 2009-04-09 20:38:20 UTC
That makes sense. Good to know, thanks for explaining it.
Comment 6 Gary Richards 2009-04-09 20:44:07 UTC
Hrm, it does start now... So it's much better than previously :)

I only seem to get one php-cgi started, even though the config says 5. Previously I would see five started? Or is this expected?

The diff between my config and the default is:
isis conf.d # diff -u /etc/conf.d/spawn-fcgi{,.test}
--- /etc/conf.d/spawn-fcgi      2009-04-09 21:34:14.000000000 +0100
+++ /etc/conf.d/spawn-fcgi.test 2009-04-09 21:36:05.000000000 +0100
@@ -31,8 +31,8 @@
 # extension but not always. For PHP, you should usually point this to
 # /usr/bin/php-cgi.
 #
-#FCGI_PROGRAM=/usr/bin/php-cgi
-FCGI_PROGRAM=
+FCGI_PROGRAM=/usr/bin/php-cgi
+#FCGI_PROGRAM=

 # The number of child processes to spawn. The default is 1.
 #
@@ -46,20 +46,20 @@
 # The user and group to run your application as. If you do not specify these,
 # the application will be run as root:root.
 #
-FCGI_USER=
-FCGI_GROUP=
+FCGI_USER=nginx
+FCGI_GROUP=nginx

 # If your application requires additional environment variables, you may
 # specify them here. See PHP example below.
 #
-ALLOWED_ENV=
+#ALLOWED_ENV=

 # PHP ONLY :: These two options are specific to PHP. The first is the number
 # of child processes to spawn. The second is the number of requests to be
 # served by a single PHP process before it is restarted.
 #
-#PHP_FCGI_CHILDREN=5
-#PHP_FCGI_MAX_REQUESTS=500
+PHP_FCGI_CHILDREN=5
+PHP_FCGI_MAX_REQUESTS=500
 #
 # For this to work you would set
-# ALLOWED_ENV="PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS"
+ALLOWED_ENV="PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS"


isis conf.d # /etc/init.d/spawn-fcgi.test start
 * Starting FastCGI application test ...
spawn-fcgi: child spawned successfully: PID: 6624    

isis conf.d # ps ax | grep php
 6624 ?        Ss     0:00 /usr/bin/php-cgi
 6950 pts/0    S+     0:00 grep --colour=auto php
Comment 7 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-04-10 08:34:28 UTC
gary: do you have the latest version of the init.d?

# $Header:
/var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.6
2009/04/09 19:48:39 bangert Exp $

the debian start-stop-daemon only supports a single -e argument, so only one variable would be exported. this is fixed in the above mentioned version.

i believe, there is also one more issue, if FCGI_PROGRAM contains whitespace (ie. has arguments). i expect to fix this later today...
Comment 8 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-04-10 09:41:13 UTC
if you have time, give version 1.7 a try - it fixes the aforementioned problem with arguments in FCGI_PROGRAM.

i am about to ask for keywording (bug #264840) of spawn-fcgi, so now is the time to come with suggestions and improvements. i will also do a version bump of to 1.6.1-r1 to make sure everybody has the latest init script installed.

in any case, thanks for your help.
kind regards
Thilo
Comment 9 Elias Probst 2009-04-12 17:09:23 UTC
Created attachment 188105 [details, diff]
A patch fixing bad whitespaces + adding a check for FCGI_PROGRAM

I have another tiny fix + enhancement for the init script:

- there were whitespaces at the end of the wrapped lines 81+82, what caused errors like "---name: command not found".
- the script didn't check whether the binary specified in FCGI_PROGRAM actually exists which caused spawn-fcgi to fail with unrelated messages like "use either -p or -s".

Please take a look at this patch and apply it if you think it is ok.

Regards,
Elias P.
Comment 10 Elias Probst 2009-04-12 17:09:54 UTC
Reopening because of the just attached patch.
Comment 11 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-04-12 17:55:55 UTC
Comment on attachment 188105 [details, diff]
A patch fixing bad whitespaces + adding a check for FCGI_PROGRAM

applied a variant of your patch. thanks for the pointer...

please open a new bug on any future findings.
thanks.