【问题标题】:Foreman terminates immediately工头立即终止
【发布时间】:2014-08-02 08:53:57
【问题描述】:

我最近在不同的计算机上安装了 OSX Ubuntu。然后我尝试为这两个操作系统安装 redis 和工头。这两个错误都没有抛出任何标志,并且似乎执行成功。但是,每当我用foreman start 开始工头时,我在两台计算机上都遇到了以下问题:

23:48:35 web.1    | started with pid 1316
23:48:35 redis.1  | started with pid 1317
23:48:35 worker.1 | started with pid 1318
23:48:35 redis.1  | [1317] 11 Jun 23:48:35.180 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
23:48:35 redis.1  | [1317] 11 Jun 23:48:35.181 * Increased maximum number of open files to 10032 (it was originally set to 256).
23:48:35 redis.1  | [1317] 11 Jun 23:48:35.181 # Creating Server TCP listening socket *:6379: bind: Address already in use
23:48:35 redis.1  | exited with code 1
23:48:35 system   | sending SIGTERM to all processes
23:48:35 worker.1 | terminated by SIGTERM
23:48:35 web.1    | terminated by SIGTERM

出于某种原因,这对我来说似乎是一个路径问题,因为 Redis 或 Foreman 似乎找不到他们需要用来成功执行的文件,但我不确定。

在 OSX 上,我使用了 gem install foremanBrew install Redis

在 Ubuntu 上,我使用了以下内容:

Redis:

$ cd ~
$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xvzf redis-stable.tar.gz
$ cd redis-stable
$ make
$ make test 

工头:

$ gem install foreman

我在 OSX 上的路径如下:

/Users/c/.rvm/gems/ruby-2.1.0/bin:/Users/c/.rvm/gems/ruby-2.1.0@global/bin:/Users/c/.rvm/rubies /ruby-2.1.0/bin:/Users/c/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

在 Ubuntu 上,我的 PATH 是:

/usr/local/bin:/usr/lib/postgresql:/usr/lib/postgresql/9.3:/usr/lib/postgresql/9.3/lib:/usr/lib/postgresql/9.3/bin:/usr /share/doc:/usr/share/doc/postgresql-9.3:/usr/share/postgresql:/usr/share/postgresql/9.3:/usr/share/postgresql/9.3/man:$PATH

Redis-server 似乎确实执行了一次,然后它失败并显示以下消息:

[1457] 12 Jun 00:02:48.481 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[1457] 12 Jun 00:02:48.482 * Increased maximum number of open files to 10032 (it was originally set to 256).
[1457] 12 Jun 00:02:48.483 # Creating Server TCP listening socket *:6379: bind: Address already in use

尝试$ redis-server stop 返回:

[1504] 12 Jun 00:05:56.173 # Fatal error, can't open config file 'stop'

我需要帮助弄清楚如何让 Foreman 和 Redis 一起工作,以便我可以在浏览器中查看位于 127.0.0.1 的本地文件

编辑

Redis 确实启动了,但是当我导航到 localhost:6379 时没有任何反应。我还尝试了寻找流程的建议。找到了

c                751   0.0  0.0  2432768    596 s005  R+    2:03PM   0:00.00 grep redis
c                616   0.0  0.0  2469952   1652 s004  S+    2:01PM   0:00.05 redis-server *:6379

尝试kill进程导致

kill: 用法:kill [-s sigspec | -n 符号 | -sigspec] pid |工作规范 ... 或 kill -l [sigspec]

【问题讨论】:

    标签: ruby-on-rails macos path redis foreman


    【解决方案1】:

    尝试使用以下命令启动 Redis 服务器:

    redis-server <path to your config file>
    

    另外,检查是否有一个 Redis 服务器实例已经在运行

    ps aux | grep redis 
    

    然后如果找到进程:

    kill <process id>
    

    重启你的redis服务器。

    【讨论】:

    • 我上面提到了服务器用redis-server启动一次。我找到了一个进程,但是输入 kill 不起作用。有关更多信息,请参阅更新后的问题
    • 在一堆错误之后,我只是恢复到“rails s”而不是“工头启动”。
    【解决方案2】:

    这一行将杀死任何现有的 redis-servers,然后启动一个新的 redis-servers。在 Foreman 中运行时,它不会发送导致 Foreman 退出的 SIGTERM,发送 SIGINT 会让 Foreman 继续。

    (ps aux | grep 6379 | grep redis | awk '{ print $2 }' | xargs kill -s SIGINT) &amp;&amp; redis-server

    在 Procfile.dev 中:

    redis: (ps aux | grep 6379 | grep redis | awk '{ print $2 }' | xargs kill -s SIGINT) &amp;&amp; redis-server

    【讨论】:

      【解决方案3】:
      1. 列出使用终端运行的redis服务器 命令:ps辅助| grep redis
      2. 在列表中记下您要终止的服务器的“pid”号示例 pid:5379
      3. 使用命令:杀死 5379

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-01-04
        • 1970-01-01
        • 1970-01-01
        • 2010-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多