• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[Suse 10.2]start-stop-daemon mit chuid?

Light Lan

Newbie
habe da das problem, dass die eine option, die das kann, bei mir einfach nicht da ist...

start-stop-daemon: unrecognized option `--chuid'
Try `start-stop-daemon --help' for more information.

gibts da ne alternative, um das als anderer benutzer automatisch starten zu lassen?

lasse das ungern als root rennen.
 
start-stop-daemon wird eher unter Debian verwendet.
SUSE bringt dafür die Programme startproc/killproc mit.

man startproc
Code:
 -g group
              Sets the group ID of the process to gid.

-u user
              Sets the user ID of the process to user.
 
OP
L

Light Lan

Newbie
startproc geht wunderbar.
danke

aber killproc nicht.

das lässt mein programm einfach weiter rennen, was daran liegen könnte, obwohl ich das pidfile angebe.
 
Und wenn du uns jetzt noch verraten würdest, wie du dein Programm startest bzw. zu stoppen versuchst, könnte dir evtl. auch jemand weiterhelfen.
 
OP
L

Light Lan

Newbie
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          FastCGI servers for Django
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     3 5
# Default-Stop:      S 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description:       Django, in order to operate with FastCGI, must be started
#                    in a very specific way with manage.py. This must be done
#                    for each DJango web server that has to run.
### END INIT INFO
#
# Author:  Guillermo Fernandez Castellanos
#          <guillermo.fernandez.castellanos AT gmail.com>.
#
# Version: @(#)fastcgi 0.1 11-Jan-2007 guillermo.fernandez.castellanos AT gmail.com
#

#### SERVER SPECIFIC CONFIGURATION
DJANGO_SITES="mysite "
SITES_PATH=/path/to/site/
RUNFILES_PATH=$SITES_PATH/run
RUN_AS=user
GROUP=group
#### DO NOT CHANGE ANYTHING AFTER THIS LINE!

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="FastCGI servers"
NAME=$0
SCRIPTNAME=/etc/init.d/$NAME

#
#       Function that starts the daemon/service.
#
d_start()
{
    # Starting all Django FastCGI processes
    for SITE in $DJANGO_SITES
    do
        echo -n ", $SITE"
        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
            echo -n " already running"
        else
            startproc -u $RUN_AS -g $GROUP \
                       -p $RUNFILES_PATH/$SITE.pid \
                       $SITES_PATH/$SITE/manage.py runfcgi \
                       socket=$RUNFILES_PATH/$SITE.sock pidfile=$RUNFILES_PATH/$SITE.pid
            chmod 440 $RUNFILES_PATH/$SITE.pid
        fi
    done
}

#
#       Function that stops the daemon/service.
#
d_stop() {
    # Killing all Django FastCGI processes running
    for SITE in $DJANGO_SITES
    do
        echo -n ", $SITE"
        killproc -G -p $RUNFILES_PATH/$SITE.pid  $SITES_PATH/$SITE/manage.py \
                          || echo -n " not running"
        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
           rm $RUNFILES_PATH/$SITE.pid
        fi
    done
}

ACTION="$1"
case "$ACTION" in
    start)
        echo -n "Starting $DESC: $NAME"
        d_start
        echo "."
        ;;

    stop)
        echo -n "Stopping $DESC: $NAME"
        d_stop
        echo "."
        ;;

    restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        d_stop
        sleep 1
        d_start
        echo "."
        ;;

    *)
        echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0
 
Code:
killproc -G -p $RUNFILES_PATH/$SITE.pid  $SITES_PATH/$SITE/manage.py \ 
                          || echo -n " not running"
Das fehlt das Signal, dass an den Prozess gesendet werden soll.

man killproc
killproc [-v] [-q] [-L] [-g|-G] [-p pid_file] [-i ingnore_file] [-c root] [-t<sec>] [-SIG] /full/path/to/executable

Also:
Code:
killproc -G -p $RUNFILES_PATH/$SITE.pid -TERM $SITES_PATH/$SITE/manage.py \
...
 
Hmmm, das ganze ist ein Python-Script.
Evtl. erwartet killproc den Pfad zum Python-Binary.
man killproc
Code:
REQUIRED
       /full/path/to/executable or name_of_kernel_thread
              Specifies  the  executable  to  which the signal should be sent, or alternatively, if the option -n is used, the name of the kernel thread.
              This argument is always required.

Schau doch mal wie genau der Prozess in der Prozesstabelle (ps, top, htop, ...) auftaucht.
 
OP
L

Light Lan

Newbie
user 11215 0.0 0.3 68564 6836 ? S 18:25 0:00 python /srv/www/django/mysite/manage.py runfcgi socket=$sock pidfi
user 11216 0.0 0.3 68564 6284 ? S 18:25 0:00 python /srv/www/django/mysite/manage.py runfcgi socket=$sock pidfi
user 11217 0.0 0.3 68564 6296 ? S 18:25 0:00 python /srv/www/django/mysite/manage.py runfcgi socket=$sock pidfi
user 11218 0.0 0.3 68564 6296 ? S 18:25 0:00 python /srv/www/django/mysite/manage.py runfcgi socket=$sock pidfi
user 11219 0.0 0.3 68564 6296 ? S 18:25 0:00 python /srv/www/django/mysite/manage.py runfcgi socket=$sock pidfi
user 11220 0.0 0.3 68564 6296 ? S 18:25 0:00 python /srv/www/django/mysite/manage.py runfcgi socket=$sock pidfi

warum reicht dem net einfach die PID?

damit kriegt der doch den prozess
 
Light Lan schrieb:
warum reicht dem net einfach die PID?

damit kriegt der doch den prozess
Frag den Programmierer des Programms.

Fakt ist, killproc braucht den vollständigen Pfad des zu beendenden Programms.
Also: Mal mit `which python` + PID versucht?
 
OP
L

Light Lan

Newbie
Code:
d_stop() {
    # Killing all Django FastCGI processes running
    for SITE in $DJANGO_SITES
    do
        echo -n ", $SITE"
	start-stop-daemon --stop -p $RUNFILES_PATH/$SITE.pid \
                          || echo -n " not running"
        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
           rm $RUNFILES_PATH/$SITE.pid
        fi
    done
}

das geht nun..
(auch wenns evtl nich ganz sauber is startproc und start-stop-daemon zu verwenden?)
 
Oben