【问题标题】:Thin server auto restart script瘦服务器自动重启脚本
【发布时间】:2014-10-31 11:52:40
【问题描述】:

我是 ubuntu 的新手,我在 azure 上遇到了一个问题,由于微软的维护,虚拟机会自动重启。

因此,我的应用程序出现故障。 他们(Windows)方面也没有确认何时重新启动/系统更新。

即使我启动瘦服务器,我如何保持它为特定端口打开,即端口 3000,3001,3002,3003.or 等等..请告诉我。

我浏览了各种博客,并在init.d 中进行了更改,以使瘦服务器在重新启动时自动启动。

user: root
group: webuser
pid: tmp/pids/thin.pid
timeout: 30
wait: 30
log: log/thin.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
servers: 1
threaded: true
no-epoll: true
daemonize: true
socket: tmp/sockets/thin.sock
chdir: webuser/app
tag: hey aux

上述方法我都试过了,但都失败了。

以下是我的etc/init.d thin文件:-

# Do NOT "set -e"

DAEMON=/usr/bin/thin
SCRIPT_NAME=/etc/init.d/thin

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

run_action() {
        ACTION="$1"

    if [ -x /usr/bin/ruby1.8 ]; then
        /usr/bin/ruby1.8 $DAEMON $ACTION --all /etc/thin1.8
    fi

    if [ -x /usr/bin/ruby1.9.1 ]; then
        /usr/bin/ruby1.9.1 $DAEMON $ACTION --all /etc/thin1.9.1
    fi

}

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

:

我不知道脚本是对还是错。但是代码似乎不起作用。 谁能帮我解决这个问题。 提前非常感谢

【问题讨论】:

  • 你能发布你的init.d 脚本吗?
  • @Ash 我已在 etc/init.d 文件夹中添加了上述名为 thin 的配置文件。如有必要,请告诉我任何更改。谢谢
  • @Ash,,上面写的代码是否正确。请告诉我。我坚持下去
  • @ravikanth 你能帮我解决这个问题吗?浏览了你在 powershell 上的博客,我想你可以帮我解决这个问题。
  • 我认为这个问题是主题,但你可能会在 SE 站点上解决有关服务器的服务器维护问题,serverfault.com

标签: ruby ubuntu azure configuration thin


【解决方案1】:

也许你可以使用chkconfig。 使用以下命令检查thin 是否为on

chkconfig | grep thin

如果不是(也许在你的情况下)添加它:

chkconfig thin on

【讨论】:

  • 好的,我去看看@christos
  • 我得到 chkconfig is not available (package) and it is not available
  • 查看this link
  • @Christos..我已经完成了..安装了 sysv-rc-conf 但是它不起作用
  • @Christos..另外我如何设置我正在运行的应用程序的端口,以便它在重新启动后立即启动
【解决方案2】:

您可能想使用this script 来瘦身。不过根据我的经验,最好使用Foremanupstart 来管理启动时启动的应用程序。效果更好,更容易配置。

除此之外,我不确定我是否理解您的堆栈:您要在 Azure 上的 Windows 2012 服务器上运行的 Ubuntu VM 上部署 ruby​​ Web 应用程序?

【讨论】:

  • 感谢您的帮助..将尝试以下内容。谢谢
猜你喜欢
  • 2021-03-24
  • 1970-01-01
  • 1970-01-01
  • 2014-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-20
  • 2012-11-22
相关资源
最近更新 更多