openstreetmap / mod_tile

Renders map tiles with mapnik and serves them using apache
http://wiki.openstreetmap.org/wiki/Mod_tile
GNU General Public License v2.0
290 stars 191 forks source link

Add sysv init script #4

Closed xEtherealx closed 3 years ago

xEtherealx commented 11 years ago

Example script (basic but fully functional) provided.

/etc/init.d/renderd

#!/bin/bash
#
# renderd        Startup script for renderd
#
# chkconfig: - 63 50
# description: Mapnik rendering daemon
# processname: renderd
# config: /usr/local/etc/renderd.conf
# pidfile: /var/run/renderd/renderd.pid
#
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Mapnik rendering daemon"
NAME=renderd
DAEMON=/usr/local/bin/$NAME
DAEMON_ARGS="-c /usr/local/etc/renderd.conf"
lockfile=${LOCKFILE-/var/lock/subsys/$NAME}
pidfile=/var/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
RUNASUSER=geo
STOP_TIMEOUT=${STOP_TIMEOUT-10}

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
#. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
start() {
    echo -n $"Starting $DESC" "$NAME: "
    mkdir -p /var/run/renderd
    chown $RUNASUSER /var/run/renderd
    # Return
    #   0 if daemon has been started
    daemon --pidfile=$pidfile --user $RUNASUSER $DAEMON $DAEMON_ARGS
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch ${lockfile}
    return $RETVAL
}

#
# Function that stops the daemon/service
#
stop() {
        echo -n $"Stopping $DESC" "$NAME: "
        killproc -p ${pidfile} -d ${STOP_TIMEOUT} $NAME
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}

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

:
springmeyer commented 11 years ago

why is this needed? Unless you plan to offer to maintain this script for many years into the future I would recommend just posting it to the osm2pgsql as a resource for others and not including in the source code.

apmon commented 11 years ago

There is already an init script in the debian subdir of the repository, so it seems reasonable to include an init script for fedora as well. The question is where best to put it and what to call it to keep a bit of order in the directory.

Also, the script does actually look very similar to the debian script, so I am wondering if it is possible to unify the two init scripts?

jcollie commented 11 years ago

Fedora has been moving to systemd service files, so there's no point in including an init.d script for that. RHEL 6 and derivatives could still use an init script. As for maintenance, once you have one that works well there's not usually a lot of changes to be made.

Looking quickly at the above script though I'd change the paths to use /usr and not /usr/local. /etc/default is a Debianism, Fedora/RedHat uses /etc/sysconfig. If this was a pull request I'd be able to comment on individual lines and I'd have a bit more to say.

xEtherealx commented 11 years ago

I'd be happy to maintain the file if that floats your boat, but as previously stated it should really need to maintenance. The path locations are as installed with no --prefix flag given in the configuration step, and the /etc/default is a copy/paste error.

AliWieckowicz commented 7 years ago

Could really use some guidance on creating this script for the rhel 7.2 distribution.

pantierra commented 3 years ago

To me it seems this is an old issue. Most distros -including rhel from version 7 on - rely on systemd. I'm going to close this issue, please contribute to #218 for supporting a systemd service unit when compiling and #232 for overall support for Fedora and Red Hat.