AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[ruby](server)

Martin Hope
Ilya Cherevkov
Asked: 2020-03-29 13:23:32 +0800 CST

Puma & NGINX 上游超时(110:连接超时)

  • 0

访问在 Nginx 代理后面使用 systemd 服务运行的 Puma 应用程序会导致 nginx error.log 中出现以下错误:

 *6 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 1.2.3.4, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/deploy/opt/app/shared/sockets/puma.app.sock/", host: "mydomain.com"

Puma 服务日志没有错误。

不过,在本地(在 nginx 之前)手动运行 Puma 应用程序不会产生任何错误。同样,在 http 代理而不是 puma unix 套接字上运行相同的应用程序也可以正常工作,允许 Nginx 正确地服务器请求。所以看起来问题不在于我的后端红宝石。

堆

  • 彪马 4.3.3
  • 罗达 3.30.0
  • RBenv Ruby 2.7.0
  • Nginx 1.14.0

/etc/nginx/sites_available/mydomain.com

upstream app {
  server unix:/home/deploy/opt/app/shared/sockets/puma.app.sock;
}

server {
  listen 80;
  server_name mydomain.com;
  root /home/deploy/opt/app/public;

  location / {
    try_files $uri @puma;
  }

  location @puma {
    include proxy_params;

    proxy_pass http://app;
  }
}

/etc/systemd/system/puma-app.service

[Unit]
Description=Puma HTTP Server
After=network.target

[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple

# Preferably configure a non-privileged user
User=deploy
Group=sudo

# Specify the path to your puma application root
WorkingDirectory=/home/deploy/opt/app

# Helpful for debugging socket activation, etc.
Environment=DEBUG=1
EnvironmentFile=/home/deploy/opt/app/.env

# The command to start Puma
ExecStart=/home/deploy/.rbenv/shims/bundle exec puma -C /home/deploy/opt/app/config/puma.rb

TimeoutSec = 15
Restart=always

[Install]
WantedBy=multi-user.target

/home/deploy/opt/app/config/puma.rb

# Change to match your CPU core count
workers ENV.fetch("PUMA_WORKERS") { 1 }

# Min and Max threads per worker
threads ENV.fetch("PUMA_MIN_THREADS") { 1 }, ENV.fetch("PUMA_MAX_THREADS") { 10 }

app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"

# Set up socket location
bind "unix://#{shared_dir}/sockets/puma.app.sock"

# Redirect STDOUT to log files
stdout_redirect "#{app_dir}/log/puma.stdout.log", "#{app_dir}/log/puma.stderr.log", true

# Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.app.pid"
state_path "#{shared_dir}/pids/puma.app.state"
rackup app_dir

activate_control_app
ruby timeout nginx
  • 1 个回答
  • 1447 Views
Martin Hope
Hendrik
Asked: 2016-10-26 07:21:52 +0800 CST

systemd 命令失败 /bin/bash not found

  • 0

目前正在尝试使新的 systemd 脚本正常工作。该脚本包含以下内容:

ExecStart=/bin/bash -lc 'bundle exec sidekiq -e production'

然而,这似乎不起作用。

然后我得到的错误是:

Failed at step CHDIR spawning /bin/bash: No such file or directory

我需要将命令作为登录 shell 执行。

ubuntu ruby systemd
  • 2 个回答
  • 6401 Views
Martin Hope
asciiphil
Asked: 2016-09-27 06:27:50 +0800 CST

是否有一种简单的方法可以为当前安装的 Ruby 版本安装 Ruby gem?

  • 0

这似乎应该是显而易见的,但我一直无法找到一种方法来做到这一点。

我的基本问题是:我在 Scientific Linux 6 系统(来自基本存储库)上安装了 Ruby 1.8.7。我正在尝试通过 安装一些 gem gem install,但我遇到了很多需要 ruby​​ 1.9 或更高版本的 gem。

我可以通过参数指定单个 gem 版本-v,但gem install似乎总是选择可用于任何 gem 依赖项的最高版本,所以即使我限制了我想要的 gem 的版本,我的安装仍然会失败,因为其中一个依赖项将需要 Ruby 1.9。我想要的一些 gem 的依赖树很深很宽;手动找出我需要的每个依赖项的哪个版本,然后手动安装每个所需的 gem,然后才能按照自己的方式工作,这将花费大量时间。(这就是依赖管理应该解决的问题。)

那么:有没有办法告诉 Ruby,“安装 gem foo,只使用可以与当前安装的 Ruby 版本一起使用的 gem”?(甚至,“安装gem foo的xyz版本,仅使用可与当前安装的 Ruby 版本一起使用的 gem”?)

正如我所提到的,我碰巧在 Scientific Linux 6 上运行 Ruby 1.8.7,但我怀疑任何解决方案都将是特定于平台的。

ruby gem
  • 2 个回答
  • 39 Views
Martin Hope
mlwrm
Asked: 2016-04-21 06:46:02 +0800 CST

我在哪里可以获得 postfix 日志示例?

  • 0

我必须为 ruby​​ 上的 postfix 日志编写解析器。它应该找到反弹,将其格式化为 JSON 并发送到某个地方。我不是系统管理员,不想在我的笔记本电脑上安装 postfix 服务器。我在哪里可以找到这样的文件来使用?有人可以寄吗?

ruby postfix logparser
  • 2 个回答
  • 2432 Views
Martin Hope
Marc Riera
Asked: 2016-04-13 22:41:36 +0800 CST

如何解决不同 gem 依赖项之间的冲突

  • 2

让我们看看是否有人可以帮助我,我不知道我在做什么。

服务器是 debian 8.4 ,完全更新。

我还使用“gem update”更新了 gems,所有可能的错误和警告都已修复。

我正在安装 redmine_git_hosting 并且发生了这种情况:

root@esplx345:/usr/share/redmine# bundle install --without development test
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break
this application for all non-root users on this machine.
Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.
Your Gemfile lists the gem redcarpet (~> 3.3.2) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Fetching https://github.com/jbox-web/gitolite-rugged.git
Fetching https://github.com/jbox-web/grack.git
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "rack":
  In snapshot (Gemfile.lock):
    rack (= 1.5.5)

  In Gemfile:
    rails (~> 4.1.4) was resolved to 4.1.15, which depends on
      actionpack (= 4.1.15) was resolved to 4.1.15, which depends on
        rack (~> 1.5.2)

    gitlab-grack was resolved to 2.0.0.pre, which depends on
      rack (~> 1.4.1)

    rack-openid was resolved to 1.4.2, which depends on
      rack (>= 1.1.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
root@esplx345:/usr/share/redmine#

我用谷歌搜索并尝试了很多东西,但没有任何接缝可以工作。

我的系统上有以下宝石:

root@esplx345:/usr/share/redmine# gem update
Updating installed gems
Nothing to update
root@esplx345:/usr/share/redmine# gem list

*** LOCAL GEMS ***

actionmailer (4.2.6, 4.1.15, 4.1.8)
actionpack (4.2.6, 4.1.15, 4.1.8)
actionpack-action_caching (1.1.1)
actionview (4.2.6, 4.1.15, 4.1.8)
activejob (4.2.6)
activemodel (4.2.6, 4.1.15, 4.1.8)
activerecord (4.2.6, 4.1.15, 4.1.8)
activesupport (4.2.6, 4.1.15, 4.1.8)
arel (7.0.0, 6.0.3, 5.0.1.20140414130214)
atomic (1.1.99, 1.1.16)
awesome_nested_set (3.0.3, 3.0.0)
bigdecimal (1.2.7, default: 1.2.4)
builder (3.2.2)
bundler (1.11.2, 1.7.4)
celluloid (0.17.3, 0.15.2)
celluloid-essentials (0.20.5)
celluloid-extras (0.20.5)
celluloid-fsm (0.20.5)
celluloid-pool (0.20.5)
celluloid-supervision (0.20.5)
coderay (1.1.1, 1.1.0)
coffee-rails (4.1.1, 4.0.1)
coffee-script (2.4.1, 2.2.0)
coffee-script-source (1.10.0, 1.3.3)
concurrent-ruby (1.0.1)
erubis (2.7.0)
eventmachine (1.2.0.1, 1.0.3)
execjs (2.6.0, 2.2.1)
fcgi (0.9.2.1)
ffi (1.9.10, 1.9.6)
gitlab-grack (2.0.2)
globalid (0.3.6)
hike (2.1.3, 1.2.1)
hitimes (1.2.3)
i18n (0.7.0, 0.6.9)
io-console (0.4.5, default: 0.4.2)
jbuilder (2.4.1, 2.1.3)
jquery-rails (4.1.1, 3.1.4, 3.1.2)
json (1.8.3, default: 1.8.1)
listen (3.0.6, 2.4.0)
loofah (2.0.3)
mail (2.6.4, 2.6.1)
mime-types (3.0, 1.25)
mime-types-data (3.2016.0221)
mini_portile2 (2.1.0, 2.0.0)
minitest (5.8.4, 5.4.2, default: 4.7.5)
multi_json (1.11.2, 1.10.1)
mysql2 (0.4.3, 0.3.20, 0.3.16)
net-http-persistent (2.9.4, 2.9)
net-ldap (0.14.0, 0.8.0)
nokogiri (1.6.7.2)
oj (2.15.0, 2.10.3)
pkg-config (1.1.7)
polyglot (0.3.5, 0.3.4)
power_assert (0.2.7)
protected_attributes (1.1.3, 1.0.8)
psych (2.0.17, default: 2.0.5)
rack (1.6.4, 1.5.5, 1.5.2)
rack-openid (1.4.2)
rack-test (0.6.3, 0.6.2)
rails (4.2.6, 4.1.15, 4.1.8)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.7)
rails-html-sanitizer (1.0.3)
railties (4.2.6, 4.1.15, 4.1.8)
rake (11.1.2, 10.3.2, default: 10.1.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7, 0.9.5)
rdoc (4.2.2, default: 4.1.0)
redcarpet (3.3.4, 3.1.2)
request_store (1.3.1, 1.1.0)
rmagick (2.15.4, 2.13.2)
ruby-openid (2.7.0, 2.5.0)
rubygems-update (2.6.3)
sass (3.4.22, 3.4.6)
sass-rails (5.0.4, 4.0.3)
sdoc (0.4.1)
spring (1.7.1, 1.1.3)
sprockets (3.6.0, 2.12.3)
sprockets-rails (3.0.4, 2.3.3, 2.1.3)
sqlite3 (1.3.11, 1.3.9)
test-unit (3.1.8, default: 2.1.5.0)
thor (0.19.1)
thread_safe (0.3.5, 0.3.3)
tilt (2.0.2, 1.4.1)
timers (4.1.1, 1.1.0)
treetop (1.6.5, 1.4.15)
turbolinks (2.5.3, 2.2.2)
tzinfo (1.2.2, 1.1.0)
uglifier (3.0.0, 2.5.3)
will_paginate (3.1.0)
yajl-ruby (1.2.1, 1.2.0)
root@esplx345:/usr/share/redmine#

非常感谢您的帮助。

debian ruby redmine rubygems
  • 2 个回答
  • 31191 Views
Martin Hope
Matt John
Asked: 2015-08-06 12:42:24 +0800 CST

从文件中为 VM 设置 MAC 地址

  • 2

我不确定这是否完全可能,所以认为值得一问。我想使用 Vagrant 允许用户在需要时启动 VM。但是,在我们的网络设备上必须通过它们的 MAC 地址进行注册。创建地址池不是问题,但是否可以为 VM 选择地址,即分步过程:

  1. 读取 MAC 地址文件
  2. 选择未使用的 MAC 地址
  3. 启动虚拟机并设置 MAC 地址

希望有人能对此有所了解,因为我的谷歌搜索失败了。

ruby
  • 2 个回答
  • 227 Views
Martin Hope
Pradeep Gupta
Asked: 2014-03-26 09:03:12 +0800 CST

想通过使用脚本为tightvnc服务器提供密码

  • 0

我正在使用 ruby​​ 脚本在我的 ubuntu 机器上安装tightvnc 服务器,我的脚本包含以下内容:

#!/usr/bin/ruby env    
`sudo apt-get --force-yes -y install tightvncserver`
`printf "%s\n%s\n" "demo123" "demo123" | vncserver :1`

我使用 printf 方式,因为 vncserver 在终端上要求输入密码,但是这种方式失败了,他们有没有更好的方法来解决这个问题?

我想使用 ruby​​ 脚本提供密码,这样终端就不会提示并要求用户提供密码。希望这清楚

ruby
  • 1 个回答
  • 85 Views
Martin Hope
Darren Beale
Asked: 2014-02-14 22:49:01 +0800 CST

rvm ruby​​ install 设置路径失败

  • 0

我以前从未使用过 Ruby,所以这个和周围的术语对我来说是新的;我只进行安装,所以我有一个运行特定应用程序的基础。

我需要 Ruby 1.9.3,据我了解,我应该使用 RVM,因为它会使版本冲突变得不那么复杂(我使用的是 Ubuntu 12.04 LTS,并且似乎已经有 1.8 和 1.9.1)。

问题是我仍然遇到版本冲突,请问我做错了什么?

详情如下:

在香草 ubuntu 12.04 LTS 上,我安装 rvm & bundler

sudo apt-get install ruby-bundler ruby-rvm

我的项目根目录中有一个 .rvmrc 文件,其中包含:

rvm use 1.9.3-p484@project-root --create

我已经执行了 sudo rvm reload

然后我告诉 rvm 安装一个特定的 ruby

sudo rvm install ruby-1.9.3-p484

它会呕吐

为 /usr/share/ruby-rvm/rubies/ruby-1.9.3-p484/bin/ruby 安装 ruby​​gems

错误:运行错误 'GEM_PATH="/usr/share/ruby-rvm/gems/ruby-1.9.3-p484:/usr/share/ruby-rvm/gems/ruby-1.9.3-p484@global:/usr /share/ruby-rvm/gems/ruby-1.9.3-p484:/usr/share/ruby-rvm/gems/ruby-1.9.3-p484@global" GEM_HOME="/usr/share/ruby-rvm/ gems/ruby-1.9.3-p484" "/usr/share/ruby-rvm/rubies/ruby-1.9.3-p484/bin/ruby" "/usr/share/ruby-rvm/src/rubygems-1.6. 2/setup.rb"',请阅读 /usr/share/ruby-rvm/log/ruby-1.9.3-p484/rubygems.install.lo

日志包含以下内容:

/usr/share/ruby-rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems.rb:483:in find_files': undefined methodmap' for Gem::Specification:Class (NoMethodError) from /usr/ share/ruby-rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems.rb:1108:in load_plugins' from /var/cache/ruby-rvm/src/rubygems-1.6.2/lib/rubygems/gem_runner.rb:84:in '来自 /usr/share/ruby-rvm/rubies/ruby-1.9.3- p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /usr/share/ruby-rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' 来自 /usr/share/ruby-rvm/src/rubygems-1.6.2/setup.rb:25:

看起来与 v1.9.1 有冲突?

如果我继续运行sudo bundle install(我有一个带有一些条目的 Gemfile),我会得到一个不同的错误,暗示捆绑器正在使用 ruby​​ 1.8!

安装 nokogiri (1.6.1) /usr/lib/ruby/vendor_ruby/1.8/rubygems/installer.rb:388:in `ensure_required_ruby_version_met': nokogiri 需要 Ruby 版本 >= 1.9.2。(宝石::安装错误)

请问我做错了什么?

我可以提供的唯一其他重要信息是输出,rvm info如您所见,我的路径为空且“二进制”不正确。

系统:

系统: uname: "Linux ubuntu 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 15:31:16 UTC 2013 i686 i686 i386 GNU/Linux" bash: "/bin/bash => GNU bash,版本 4.2.25(1)-release (i686-pc-linux-gnu)" zsh: " => not installed"

rvm:版本:“Wayne E. Seguin 的 rvm 1.6.9 ([email protected]) [ https://rvm.beginrescueend.com/] ”

家园:宝石:“未设置”红宝石:“未设置”

二进制文件: ruby​​:“/usr/bin/ruby” irb:“/usr/bin/irb” gem:“/usr/bin/gem” rake:“”

环境:PATH:“/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/share/ruby-rvm/bin :/usr/share/ruby-rvm/bin" GEM_HOME: "" GEM_PATH: "" MY_RUBY_HOME: "" IRBRC: "" RUBYOPT: "" gemset: ""

/usr/bin/ruby -v返回 1.8.7

ruby
  • 1 个回答
  • 997 Views
Martin Hope
Timo
Asked: 2014-01-19 03:49:15 +0800 CST

继续捆绑器安装

  • 1

我正在尝试在 Debian Wheezy 上安装 Gitorious。gitorious 使用捆绑器进行自动安装。

当我运行“捆绑安装”时(不仅在安装 gitorious 时,还安装 redmine 例如)我有时会收到如下错误:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

~/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling houdini_js_e.c
compiling houdini_xml_e.c
compiling houdini_html_u.c
compiling houdini_html_e.c
compiling houdini_uri_u.c
compiling escape_utils.c
escape_utils.c: In function ‘rb_eu_escape_html_as_html_safe’:
escape_utils.c:126:2: error: assignment of read-only member ‘klass’
make: *** [escape_utils.o] Error 1

make failed, exit code 2

Gem files will remain installed in ~/.rvm/gems/ruby-2.1.0/gems/escape_utils-0.3.2 for inspection.
Results logged to ~/.rvm/gems/ruby-2.1.0/extensions/x86_64-linux/2.1.0/escape_utils-0.3.2/gem_make.out
An error occurred while installing escape_utils (0.3.2), and Bundler cannot continue.
Make sure that `gem install escape_utils -v '0.3.2'` succeeds before bundling.

在这个特定示例中,我能够通过更改给定目录中的源来修复构建错误。(我从 github 复制了最新的源代码,它解决了问题https://github.com/brianmario/escape_utils/issues/42)。

然后我成功执行了“make && make install && ~/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb”。

修复 gem 后如何继续我的“捆绑安装”?当我重新执行“捆绑安装”时,gem 只是重新获取并重新编译,当然会出现相同的错误,完全放弃我的更改。

到目前为止我尝试了什么:

  • 使用“bundle package”生成缓存并执行“bundle install --local”
  • 将编译好的 gem 复制到 gitorious 目录。
  • 在固定源上执行“gem install”。

在此类错误之后继续“捆绑安装”的正确方法是什么?

ruby
  • 1 个回答
  • 756 Views
Martin Hope
Drew Mills
Asked: 2014-01-09 13:13:53 +0800 CST

为什么我不能从 Ruby 脚本运行 wbadmin

  • 1

我可以像这样从命令行运行 wbadmin:

$ c:\windows\system32\wbadmin.exe -?

它有效(我得到了一个适当的帮助信息,这里省略了)。但是,当我在 Ruby 中尝试它时(就像在这个 IRB 会话中一样:)

irb(main):001:0> w=IO.popen('c:\windows\system32\wbadmin.exe -?')

我收到以下错误:

Errno::ENOENT: No such file or directory - c:\windows\system32\wbadmin.exe -?
        from (irb):1:in `popen'
        from (irb):1
        from C:/Ruby193/bin/irb:12:in `<main>'

这使我无法像这样运行 wbadmin。

任何想法为什么?

ruby
  • 1 个回答
  • 145 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve