首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Windows上使用Rubber部署到EC2

在Windows上使用Rubber部署到EC2
EN

Stack Overflow用户
提问于 2014-04-16 01:41:12
回答 1查看 90关注 0票数 0

我正在尝试将我的Rails应用程序部署到亚马逊EC2实例上,但一直收到相同的错误。

代码语言:javascript
复制
Trying to enable root login

c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rubber-2.8.0/lib/rubber/recipes/rubber/setup.rb:173:in `read': No such file or directory - /etc/hosts (Errno::ENOENT)

此错误指向该文件中的此块

代码语言:javascript
复制
desc <<-DESC
  Sets up local aliases for instance hostnames based on contents of instance.yml.
  Generates/etc/hosts for local machine
DESC
required_task :setup_local_aliases do
  hosts_file = '/etc/hosts'

  # Generate /etc/hosts contents for the local machine from instance config
  delim = "## rubber config #{rubber_env.domain} #{Rubber.env}"
  local_hosts = delim + "\n"
  rubber_instances.each do |ic|
    # don't add unqualified hostname in local hosts file since user may be
    # managing multiple domains with same aliases
    hosts_data = [ic.full_name, ic.external_host, ic.internal_host]

    # add the ip aliases for web tools hosts so we can map internal tools
    # to their own vhost to make proxying easier (rewriting url paths for
    # proxy is a real pain, e.g. '/graphite/' externally to '/' on the
    # graphite web app)
    if ic.role_names.include?('web_tools')
      Array(rubber_env.web_tools_proxies).each do |name, settings|
        hosts_data << "#{name}-#{ic.full_name}"
      end
    end

    local_hosts << ic.external_ip << ' ' << hosts_data.join(' ') << "\n"
  end
  local_hosts << delim << "\n"

  # Write out the hosts file for this machine, use sudo
  *LINE 173* existing = File.read(hosts_file)
  filtered = existing.gsub(/^#{delim}.*^#{delim}\n?/m, '')

  # only write out if it has changed
  if existing != (filtered + local_hosts)
    logger.info "Writing out aliases into local machines #{hosts_file}, sudo access needed"
    Rubber::Util::sudo_open(hosts_file, 'w') do |f|
      f.write(filtered)
      f.write(local_hosts)
    end
  end
end

我将文本*LINE 173*添加到实际的行中,错误是引用。

我找到了关于它的Google Group帖子,但我不确定如何更改Windows的路径

https://groups.google.com/forum/#!topic/rubber-ec2/LFk0NgrOtyY

任何帮助都将不胜感激。我再次尝试将Rails应用程序部署到Windows8机器上的EC2实例。

EN

回答 1

Stack Overflow用户

发布于 2014-04-17 06:22:05

Windows中的等效文件为

代码语言:javascript
复制
C:\Windows\System32\drivers\etc\hosts

此代码可能难以写入该文件,因为它需要特权访问。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23090759

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档