A
A
asdasdfasf2016-04-21 13:41:13
Ruby on Rails
asdasdfasf, 2016-04-21 13:41:13

How to launch a site on Ruby and Unicorn?

So, given: A site on rails that needs to be transferred from one server (hereinafter referred to as the source) to another (hereinafter referred to as the server) without access to the original repository. The question was partly discussed here How to correctly migrate a live site to Ruby on rail... , but then it was more of a theoretical discussion. Now specific questions have gone:
What has been done:
0. Ubuntu 14.04 LTS is loaded on VirtualBox, rvm is up, the latest version of ruby ​​is installed and the version that was used on the source. I did this:

<br>
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3<br>
\curl -sSL https://get.rvm.io	| bash -s stable --rails -скачиваем и устанавливаем РВМ с последней версией рельс<br>
rvm install 2.2.0 - скачиваем нужную версию<br>
gem install unicorn - пытаемся установить Unicorn<br>
bundle install - пытаемся установить сайт<br>

1. Mongo base copied and moved to a new server;
2. The folder with the site was copied with a simple copy-paste;
When transferring the site, it is not possible to start Unicorn correctly, in the original it was launched like this:
cd /path/to/repository/current && rvm use 2.2.0 && bundle exec unicorn -c /path/to/repository/current/config/unicorn.rb -D -E production

But this throws an error:
Using /home/master/.rvm/gems/ruby-2.2.0
/path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio.rb:21:in `require': /path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio_ext.so: wrong ELF class: ELFCLASS64 - /path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio_ext.so (LoadError)
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio.rb:21:in `<top (required)>'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn.rb:6:in `require'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn.rb:6:in `<top (required)>'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/launcher.rb:9:in `require'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/launcher.rb:9:in `<top (required)>'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/bin/unicorn:3:in `require'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/bin/unicorn:3:in `<top (required)>'
        from /path/to/repository/shared/bundle/ruby/2.2.0/bin/unicorn:23:in `load'
        from /path/to/repository/shared/bundle/ruby/2.2.0/bin/unicorn:23:in `<main>'

Google does not say anything intelligible, objectively there is not enough knowledge to understand what he wants. Attention, the question is: What needs to be done now to launch the site, and how should it be done correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
caution, 2016-04-21
@caution

bundle install - we are trying to install the site - it's just a thrill,
I hope you did this:
'/path/to/repository/'
by hand, otherwise everything is very bad.

R
Roman Mirilaczvili, 2016-04-22
@2ord

Using /home/master/.rvm/gems/ruby-2.2.0
/path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio.rb:21:in `require': /path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio_ext.so: wrong ELF class: ELFCLASS64 - /path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio_ext.so (LoadError)
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/kgio-2.9.2/lib/kgio.rb:21:in `<top (required)>'
        from /path/to/repository/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn.rb:6:in `require'
...
indicates that the kgio_ext.so library was taken from an old machine on which it was compiled for a different architecture (64 bit).
In a good way, it was necessary to install without copying the /path/to/repository folder, because there are bindings to the old machine. But it looks like the whole migration process was done from the left foot.
The procedure for preparing to install the web application should be as follows:
  1. Ruby is strongly recommended to be installed through the regular installation manager of the system (apt), otherwise updates with the elimination of vulnerabilities will not occur .
    Installing via rvm or rbenv with sudo rights is fraught with security problems for the system running the site, since the versions of installed interpreters are fixed and are not automatically updated by the system. They need to be updated manually.
    ruby 2.2.0 has CVE vulnerabilities . If the standard Ubuntu version 2.0 is not enough, then you can install version 2.2 using the PPA repository https://www.brightbox.com/docs/ruby/ubuntu/ (Installation chapter)
    sudo apt-get install ruby2.2 ruby2.2-dev ruby-switch
    sudo ruby-switch --set ruby2.2

    bundle itself - a utility for resolving application dependencies specified in the Gemfile. Read at bundler.io/#getting-started
    Different gem-dependencies of the application may require compilation from C/C++ sources (wrappers over third-party libraries). They need to have the appropriate "xyz -dev " .deb packages installed via stock apt. It is impossible to know in advance which packages will be required. You need to check bundle checkif everything is in order with the root of the application and run
    bundle install --path vendor --without development test

    until all dependencies are satisfied (displays what is missing in the system).
  2. gem unicorn must also be installed. Although it is completely optional for the development mode (there is a webrick).
    Once the bundle check shows "successful", you can run
    An example configuration for unicorn.rb can be found at unicorn.bogomips.org/examples/unicorn.conf.rb
    Then follow the instructions:
    https://launchschool.com/blog/setting-up-your-prod...
    https://www.digitalocean.com/community/tutorials/h...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question