如何在系统启动时启动精简进程

时间:2011-11-12 03:45:59

标签: ruby-on-rails

我正在使用Debian风味的linux系统。我正在使用瘦Web服务器在我的应用程序中获取调用的实时状态。当我使用/etc/init.d/thin start时,这个过程开始了。我使用update-rc.d -f thin默认值来使瘦进程在系统引导时启动。添加条目后,我重新启动了系统,但是精简过程没有开始。我检查了apache2,它在系统启动时正常启动。我在init.d中的瘦脚本如下,

DAEMON=/usr/local/lib/ruby/gems/1.9.1/bin/thin
SCRIPT_NAME=/etc/init.d/thin
CONFIG_PATH=/etc/thin           

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

case "$1" in
start)                        
    $DAEMON start --all $CONFIG_PATH
    ;;                      
stop)                         
    $DAEMON stop --all $CONFIG_PATH
    ;;                      
restart)                      
    $DAEMON restart --all $CONFIG_PATH
    ;;
*)
    echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
    exit 3
    ;;
esac

我在/ etc / thin中的配置文件如下。

user_status.yml

 --- 
 chdir: /FMS/src/FMS-Frontend
 environment: production
 address: localhost              
 port: 5000                      
 timeout: 30
 log: log/thin.log               
 pid: tmp/pids/thin.pid          
 max_conns: 1024
 max_persistent_conns: 512
 require: []

 wait: 30                        
 servers: 1
 rackup: user_status.ru
 threaded: true                  
 daemonize: false

1 个答案:

答案 0 :(得分:0)

你需要一个“瘦”的包装器。 见https://rvm.io/integration/init-d。 然后,包装器路径需要在init.d脚本中替换DAEMON。 我一直忘了这个,花了好几个小时! 现在我以root身份检查了它,输入两个命令

    rvm wrapper current bootup thin
    which bootup_thin

第一个创建包装器,第二个提供它的路径。 编辑/etc/init.d/thin中的DAEMON行以使用此路径,并以

结束
    systemctl daemon-reload
    service thin restart

我假设有一个rvm的多用户安装,你也必须输入root 与

    su -

让rvm环境正确。