Cent OS上的Geoserver服务自动启动

时间:2017-04-27 06:56:43

标签: centos geoserver

我尝试使用此但收到错误:感谢任何帮助。我也试过http://docs.geoserver.org/latest/en/user/_downloads/geoserver_deb的代码 Geoserver网站,但它是为了debain。我是CentOS的新手,对此并不了解。我必须每次都手动运行statup.sh来运行服务。

Starting geoserver…
bash: /var/log/geoserver.log: Permission denied
geoserver is started

以下是自动启动脚本:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          GeoServer
# Required-Start:    $local_fs $network $named $time $syslog
# Required-Stop:     $local_fs $network $named $time $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       Starts and stops the GeoServer, which should be located at /usr/share/geoserver
### END INIT INFO

SERVICE_NAME=geoserver
START=/usr/share/geoserver/geoserver-2.10.1/bin/startup.sh
STOP=/usr/share/geoserver/geoserver-2.10.1/bin/shutdown.sh
RUNAS=test
GEOSERVER_HOME=/usr/share/geoserver/geoserver-2.10.1/
JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64

PIDFILE=/var/run/geoserver.pid
LOGFILE=/var/log/geoserver.log

start() {
  if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
    echo "$SERVICE_NAME is already running" >&2
    return 1
  fi
  echo "Starting $SERVICE_NAME…" >&2
  su -c "GEOSERVER_HOME=$GEOSERVER_HOME JAVA_HOME=$JAVA_HOME $START &> '$LOGFILE' & echo \$!" $RUNAS > "$PIDFILE"
  echo "$SERVICE_NAME is started" >&2
}

stop() {
  if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
    echo "$SERVICE_NAME is not running" >&2
    if [ -f "$PIDFILE" ]; then
        echo "Removing $PIDFILE"
        rm $PIDFILE
    fi
    return 1
  fi
  echo "Stopping $SERVICE_NAME…" >&2
  su -c "$STOP &> '$LOGFILE' & echo \$!" $RUNAS && kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  echo "$SERVICE_NAME has stopped" >&2
}

status() {
    printf "%-50s" "Checking $SERVICE_NAME..."
    if [ -f $PIDFILE ]; then
        PID=`cat $PIDFILE`
        if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
            printf "%s\n" "Process dead but pidfile exists"
            exit 1
        else
            echo "$SERVICE_NAME is running"
        fi
    else
        printf "%s\n" "$SERVICE_NAME is not running"
        exit 3
    fi
}

case "$1" in
  status)
    status
    ;;
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|restart|status|stop}"
esac

exit 0

1 个答案:

答案 0 :(得分:0)

正在运行tomcat的用户必须能够写入GeoServer数据目录和日志文件位置(在本例中为/var/log/)。我忘记了用户centos使用的确切内容,但它可能是tomcattomcat7