如何在自动加载CentOS中添加TileStream

如何在自动加载CentOS中添加TileStream

我是 CentOS 新手。我已经安装了tilestream。现在希望tilestream在系统重新启动后自动启动。这样做教程

/etc/init/tilestream.conf

#!upstart
#description "node.js chatapp server"
#author      "subicura"

start on startup
stop on shutdown

script
   export HOME="/home/myuser"#

   echo $$ > /var/run/tilestream.pid
   exec /usr/bin/node /usr/bin/tilestream >> /var/log/tilestream.log 2>&1
end script

pre-start script
   # Date format same as (new Date()).toISOString() for consistency
   echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/tilestream.log
end script

pre-stop script
   rm /var/run/tilestream.pid
   echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/tilestream.log
end script

在 cterminal 中执行以下操作:

/sbin/start tilestream

输出:

tilestream start/running, process 2428

在日志中:

[2014-06-27T08:32:55.316Z] (sys) Starting
Creating tiles dir /home/myuser#/Documents/MapBox/tiles
Started [Server Tile].
Started [Server Core:8888].

但 TileStream 不起作用。

如果我用脚本 /etc/init.d/tilestream 启动它

#!/bin/sh
### BEGIN INIT INFO
# Provides:          tilestream
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Start TileStream server
### END INIT INFO

TILESTREAM="/usr/bin/tilestream"
MAPPATH="/data"
HOST="host"
#HOST="localhost"
#UIPORT="9001"
UIPORT="8888"
#TILEPORT="9000"
TILEPORT="8888"
SUBDOMAINS="a,b,c,d"

case $1 in
    start)
        echo "Starting TileStream"
       #$TILESTREAM --tiles=$MAPPATH --host=$HOST&
       #$TILESTREAM --tiles=$MAPPATH --host=$HOST --uiPort=$UIPORT --tilePort=$TILEPORT --subdomains=$SUBDOMAINS&
       $TILESTREAM --tiles=$MAPPATH --host=$HOST --uiPort=$UIPORT --tilePort=$TILEPORT&
        ;;
    stop)
        echo "Stopping TileStream"
        #PID=`ps aux | grep $TILESTREAM | grep -v grep | awk '{print $2}'`
    PID=`ps aux | grep "tilestream" | grep -v grep | awk '{print $2}'`
        kill -9 $PID
        ;;
    restart)
        echo "Restarting TileStream"
       $0 stop
       sleep 1
       $0 start
       ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
    esac

在这种情况下一切工作正常。
有什么建议吗?

答案1

将您在 init 脚本中传递的选项附加到tilestream命令,但在stdout/in重定向之前。

相关内容