Closed dpr0 closed 4 years ago
Hello,
The last issue with Unit crash should be fixed with this patch:
diff --git a/src/nxt_application.c b/src/nxt_application.c
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -329,6 +329,10 @@ nxt_app_start(nxt_task_t *task, void *da
nxt_app = nxt_app_module_load(task, lang->file);
}
+ if (nxt_app == NULL) {
+ return NXT_ERROR;
+ }
+
if (nxt_app->pre_init != NULL) {
ret = nxt_app->pre_init(task, data);
Obviously, your app cannot start after ruby uninstall.
Regarding your question
why app start for root ruby only?
I guess root ruby is a ruby 2.5 (please confirm). Application 'football' failed to start because of missing file during it's load. If you expected application 'football' uses ruby 2.6.3 environment (please confirm), then your Unit ruby module should be built against proper ruby version. I guess you are using Unit from packages (please confirm) and packaged ruby module built for ruby from Ubuntu repository. To use newer version, please follow Configuring Ruby documentation instructions.
Your experiments with sudo
can be demystified by the fact sudo lookups ruby
binary using it's own PATH
variable. Compare: $ echo $PATH
with $ sudo bash -c 'echo $PATH'
.
1 - format disc 2 - install ubuntu server 19.10 3 - install rbenv 4 - install ruby
sudo apt update
sudo apt install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.6.3
rbenv global 2.6.3
gem install bundler
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
gem install rails -v 5.2.3
5 - install unit, unit-dev, unit-ruby
curl -sL https://nginx.org/keys/nginx_signing.key | apt-key add -
sudo curl -sL https://nginx.org/keys/nginx_signing.key | apt-key add -
wget https://packages.nginx.org/unit/ubuntu/pool/unit/u/unit-ruby/unit/unit_1.12.0-1~disco_amd64.deb
wget https://packages.nginx.org/unit/ubuntu/pool/unit/u/unit/unit_1.12.0-1~disco_amd64.deb
wget https://packages.nginx.org/unit/ubuntu/pool/unit/u/unit/unit-dev_1.12.0-1~disco_amd64.deb
sudo gdebi unit_1.12.0-1~disco_amd64.deb
sudo gdebi unit-dev_1.12.0-1~disco_amd64.deb
sudo gdebi unit-ruby_1.12.0-1~disco_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
Requires the installation of the following packages: fonts-lato javascript-common libjs-jquery libruby2.5 rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-rack ruby-test-unit ruby-xmlrpc ruby2.5 rubygems-integration zip
Ruby module for NGINX Unit
NGINX Unit is a runtime and delivery environment for modern distributed
applications. It runs the application code in multiple languages
(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
in and out of the application. Take this application server and proxy
directly in the cloud / container environments and fully control your app
dynamically via an API.
This package contains Ruby module for NGINX Unit.
Do you want to install the software package? [y/N]:y
/usr/bin/gdebi:113: FutureWarning: Possible nested set at position 1
c = findall("[[(](\S+)/\S+[])]", msg)[0].lower()
Get:1 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 fonts-lato all 2.0-2 [2698 kB]
Get:2 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 javascript-common all 11 [6066 B]
Get:3 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 libjs-jquery all 3.3.1~dfsg-3 [329 kB]
Get:4 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 rubygems-integration all 1.11 [4994 B]
Get:5 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby2.5 amd64 2.5.5-4ubuntu2 [48.8 kB]
Get:6 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby amd64 1:2.5.1 [5712 B]
Get:7 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 rake all 12.3.1-3 [44.9 kB]
Get:8 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby-did-you-mean all 1.2.1-1 [9828 B]
Get:9 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby-minitest all 5.11.3-1 [39.4 kB]
Get:10 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby-net-telnet all 0.1.1-2 [12.6 kB]
Get:11 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby-power-assert all 1.1.1-1 [11.0 kB]
Get:12 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby-test-unit all 3.2.8-1 [61.4 kB]
Get:13 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 ruby-xmlrpc all 0.3.0-2 [23.8 kB]
Get:14 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 libruby2.5 amd64 2.5.5-4ubuntu2 [3091 kB]
Get:15 http://ru.archive.ubuntu.com/ubuntu eoan/universe amd64 ruby-rack all 2.0.6-3 [79.6 kB]
Get:16 http://ru.archive.ubuntu.com/ubuntu eoan/main amd64 zip amd64 3.0-11build1 [167 kB]
Fetched 6633 kB in 0s (0 B/s)
Selecting previously unselected package fonts-lato.
(Reading database ... 77042 files and directories currently installed.)
Preparing to unpack .../00-fonts-lato_2.0-2_all.deb ...
Unpacking fonts-lato (2.0-2) ...
Selecting previously unselected package javascript-common.
Preparing to unpack .../01-javascript-common_11_all.deb ...
Unpacking javascript-common (11) ...
Selecting previously unselected package libjs-jquery.
Preparing to unpack .../02-libjs-jquery_3.3.1~dfsg-3_all.deb ...
Unpacking libjs-jquery (3.3.1~dfsg-3) ...
Selecting previously unselected package rubygems-integration.
Preparing to unpack .../03-rubygems-integration_1.11_all.deb ...
Unpacking rubygems-integration (1.11) ...
Selecting previously unselected package ruby2.5.
Preparing to unpack .../04-ruby2.5_2.5.5-4ubuntu2_amd64.deb ...
Unpacking ruby2.5 (2.5.5-4ubuntu2) ...
Selecting previously unselected package ruby.
Preparing to unpack .../05-ruby_1%3a2.5.1_amd64.deb ...
Unpacking ruby (1:2.5.1) ...
Selecting previously unselected package rake.
Preparing to unpack .../06-rake_12.3.1-3_all.deb ...
Unpacking rake (12.3.1-3) ...
Selecting previously unselected package ruby-did-you-mean.
Preparing to unpack .../07-ruby-did-you-mean_1.2.1-1_all.deb ...
Unpacking ruby-did-you-mean (1.2.1-1) ...
Selecting previously unselected package ruby-minitest.
Preparing to unpack .../08-ruby-minitest_5.11.3-1_all.deb ...
Unpacking ruby-minitest (5.11.3-1) ...
Selecting previously unselected package ruby-net-telnet.
Preparing to unpack .../09-ruby-net-telnet_0.1.1-2_all.deb ...
Unpacking ruby-net-telnet (0.1.1-2) ...
Selecting previously unselected package ruby-power-assert.
Preparing to unpack .../10-ruby-power-assert_1.1.1-1_all.deb ...
Unpacking ruby-power-assert (1.1.1-1) ...
Selecting previously unselected package ruby-test-unit.
Preparing to unpack .../11-ruby-test-unit_3.2.8-1_all.deb ...
Unpacking ruby-test-unit (3.2.8-1) ...
Selecting previously unselected package ruby-xmlrpc.
Preparing to unpack .../12-ruby-xmlrpc_0.3.0-2_all.deb ...
Unpacking ruby-xmlrpc (0.3.0-2) ...
Selecting previously unselected package libruby2.5:amd64.
Preparing to unpack .../13-libruby2.5_2.5.5-4ubuntu2_amd64.deb ...
Unpacking libruby2.5:amd64 (2.5.5-4ubuntu2) ...
Selecting previously unselected package ruby-rack.
Preparing to unpack .../14-ruby-rack_2.0.6-3_all.deb ...
Unpacking ruby-rack (2.0.6-3) ...
Selecting previously unselected package zip.
Preparing to unpack .../15-zip_3.0-11build1_amd64.deb ...
Unpacking zip (3.0-11build1) ...
Setting up javascript-common (11) ...
Setting up fonts-lato (2.0-2) ...
Setting up ruby-power-assert (1.1.1-1) ...
Setting up rubygems-integration (1.11) ...
Setting up ruby-minitest (5.11.3-1) ...
Setting up zip (3.0-11build1) ...
Setting up ruby-test-unit (3.2.8-1) ...
Setting up ruby-net-telnet (0.1.1-2) ...
Setting up libjs-jquery (3.3.1~dfsg-3) ...
Setting up ruby-did-you-mean (1.2.1-1) ...
Setting up ruby-xmlrpc (0.3.0-2) ...
Setting up rake (12.3.1-3) ...
Setting up libruby2.5:amd64 (2.5.5-4ubuntu2) ...
Setting up ruby2.5 (2.5.5-4ubuntu2) ...
Setting up ruby (1:2.5.1) ...
Setting up ruby-rack (2.0.6-3) ...
Processing triggers for libc-bin (2.30-0ubuntu2) ...
Processing triggers for man-db (2.8.7-3) ...
Selecting previously unselected package unit-ruby.
(Reading database ... 78430 files and directories currently installed.)
Preparing to unpack unit-ruby_1.12.0-1~disco_amd64.deb ...
----------------------------------------------------------------------
The Ruby module for NGINX Unit has been installed.
To check out the sample app, run these commands:
sudo service unit restart
cd /usr/share/doc/unit-ruby/examples
sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
curl http://localhost:8700/
Online documentation is available at https://unit.nginx.org
----------------------------------------------------------------------
Unpacking unit-ruby (1.12.0-1~disco) ...
Setting up unit-ruby (1.12.0-1~disco) ...
sudo service unit restart
cd /usr/share/doc/unit-ruby/examples
sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
{
"success": "Reconfiguration done."
}
ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
curl http://localhost:8700/
Hello from Unit running with Ruby 2.5.5!
sudo ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
echo $PATH
/home/deploy/.rbenv/plugins/ruby-build/bin:/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
sudo bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
sudo su
apt update
apt install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.6.3
rbenv global 2.6.3
gem install bundler
curl -sL https://nginx.org/keys/nginx_signing.key | apt-key add -
service unit stop
cd /home/deploy/
ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
gdebi unit_1.12.0-1~disco_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
NGINX Unit
NGINX Unit is a runtime and delivery environment for modern distributed
applications. It runs the application code in multiple languages
(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
in and out of the application. Take this application server and proxy
directly in the cloud / container environments and fully control your app
dynamically via an API.
Вы хотите установить этот пакет? [y/N]y
/usr/bin/gdebi:113: FutureWarning: Possible nested set at position 1
c = findall("[(/\S+[])]", msg)[0].lower()
gdebi unit-dev_1.12.0-1~disco_amd64.deb
gdebi unit-ruby_1.12.0-1~disco_amd64.deb
service unit start
curl http://localhost:8700/
Hello from Unit running with Ruby 2.5.5!
6 - rm -rf && format && install ubuntu server 19.04
su root
apt update
apt install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.6.3
rbenv global 2.6.3
gem install bundler
ruby -v
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
echo $PATH
/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
bash -c 'echo $PATH'
/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
root@userv2:~# sudo bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
wget https://packages.nginx.org/unit/ubuntu/pool/unit/u/unit/unit-dev_1.12.0-1~disco_amd64.deb
wget https://packages.nginx.org/unit/ubuntu/pool/unit/u/unit-ruby/unit/unit_1.12.0-1~disco_amd64.deb
wget https://packages.nginx.org/unit/ubuntu/pool/unit/u/unit-ruby/unit-ruby_1.12.0-1~disco_amd64.deb
apt install gdebi-core
gdebi unit_1.12.0-1~disco_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
NGINX Unit
NGINX Unit is a runtime and delivery environment for modern distributed
applications. It runs the application code in multiple languages
(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
in and out of the application. Take this application server and proxy
directly in the cloud / container environments and fully control your app
dynamically via an API.
Вы хотите установить этот пакет? [д/Н]y
/usr/bin/gdebi:113: FutureWarning: Possible nested set at position 1
c = findall("[(/\S+[])]", msg)[0].lower()
gdebi unit-dev_1.12.0-1~disco_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
Этот пакет невозможно установить
Dependency is not satisfiable: unit (= 1.12.0-1~disco)
gdebi unit-ruby_1.12.0-1~disco_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
Этот пакет невозможно установить
Dependency is not satisfiable: unit (= 1.12.0-1~disco)
curl -sL https://nginx.org/keys/nginx_signing.key | apt-key add -
git clone https://github.com/nginx/unit
cd unit
./configure
./configure ruby
deploy@userv2:~/unit$ ./configure ruby
configuring Ruby module
checking for Ruby library ... not found
checking for Ruby library in /home/deploy/.rbenv/versions/2.6.3/lib ... not found
./configure: error: no Ruby found.
deploy@userv2:~/unit$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
deploy@userv2:~/unit$ which ruby
/home/deploy/.rbenv/shims/ruby
deploy@userv2:~/unit$ ./configure ruby --ruby=/home/deploy/.rbenv/shims/ruby
configuring Ruby module
checking for Ruby library ... not found
checking for Ruby library in /home/deploy/.rbenv/versions/2.6.3/lib ... not found
./configure: error: no Ruby found.
root@userv2:/home/deploy# which ruby
/root/.rbenv/shims/ruby
root@userv2:/home/deploy# sudo which ruby
/usr/bin/ruby
deploy@userv2:~/unit$ ./configure ruby --ruby=/ruby
configuring Ruby module
checking for Ruby ... not found
./configure: error: no Ruby found.
deploy@userv2:~/unit$ ./configure ruby --ruby=ruby
configuring Ruby module
checking for Ruby library ... not found
checking for Ruby library in /home/deploy/.rbenv/versions/2.6.3/lib ... not found
./configure: error: no Ruby found.
Hello @dpr0
Thanks for your explanation! Despite the fact I prefer reading answers for my questions in natural language, I've spent the time in the exiting journey through commands and output you kindly provided.
First, I've noticed you are using wget
+ gdebi
to install Unit precompiled packages. I would suggest you to read and use installation instructions from official Unit documentation. If it is does not works for you, please let us know why.
Second, when you build Unit from sources, more information about the configure error you may find in build/autoconf.err
. In your case it was the absence of shared library, required for module:
configuring Ruby module ...
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
----------------------------------------
checking for Ruby library
/usr/bin/ld: cannot find -lruby
collect2: error: ld returned 1 exit status
----------
#include <ruby.h>
int main() {
ruby_init();
return ruby_cleanup(0);
}
----------
cc -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -I/root/.rbenv/versions/2.6.3/include/ruby-2.6.0/x86_64-linux -I/root/.rbenv/versions/2.6.3/include/ruby-2.6.0 -o build/autotest build/autotest.c -lruby -lm
----------
----------------------------------------
checking for Ruby library in /root/.rbenv/versions/2.6.3/lib
/usr/bin/ld: cannot find -lruby
collect2: error: ld returned 1 exit status
----------
#include <ruby.h>
int main() {
ruby_init();
return ruby_cleanup(0);
}
----------
cc -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -I/root/.rbenv/versions/2.6.3/include/ruby-2.6.0/x86_64-linux -I/root/.rbenv/versions/2.6.3/include/ruby-2.6.0 -o build/autotest build/autotest.c -L/root/.rbenv/versions/2.6.3/lib -Wl,-rpath,/root/.rbenv/versions/2.6.3/lib -lruby -lm
----------
/root/.rbenv/versions/2.6.3/lib
contains only libruby-static.a
. Google's answer for "rbenv install shared library" is: use RUBY_CONFIGURE_OPTS="--enable-shared" rbenv install 2.6.3
to install ruby with shared library. After that ./configure ruby
succeeded and I was able to build Unit with ruby 2.6.3 module.
Third, when you successfully build Unit with ruby 2.6.3 as root, in root home directory it will not work for you as expected. The reason is Unit processes credentials. When Unit started as root, it changes all worker processes' effective user to nobody for security reasons.
To avoid root-related issues, I would suggest to install ruby and build Unit in your (non-root) home directory under non-root user (just as recommended in official documentation). Being started as unprivileged user, Unit does not change worker process credentials and all processes running under same user with same environment.
Make sure you installed rack using gem install rack
.
If you need to start Unit as root anyway, make sure all Unit binaries, modules and language runtime files are accessed by unprivileged user. E.g. install everything in a globally accessed directory like /usr/local
.
Hello and thank you for the answers! Ruby app work normal, but ruby on rails app not started. Somebody ran ruby on rails app not in docker?
RUBY_CONFIGURE_OPTS="--enable-shared" rbenv install 2.6.3
RUBY_CONFIGURE_OPTS="--enable-shared" rbenv global 2.6.3
gem install bundler
gem install rack
git clone https://github.com/nginx/unit
cd unit
./configure --prefix=/usr/local/ # not configured without prefix ?!?!
./configure ruby
make
sudo make install
make ruby
sudo make ruby-install
sudo unitd --control unix:/var/run/control.unit.sock # start unit
./unit/test/run.py # all ok!
nano unit.config # test app
sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
sudo cat /usr/local/unit.log
{
"listeners": { "*:3000": { "pass": "applications/test" } },
"applications": {
"test": {
"type": "ruby",
"user": "deploy",
"working_directory": "/home/deploy/",
"script": "unit_test.ru"
}
}
}
2019/11/06 09:37:38 [info] 1846#1846 discovery started
2019/11/06 09:37:38 [notice] 1846#1846 module: ruby 2.6.3 "/usr/local/modules/ruby.unit.so"
2019/11/06 09:37:38 [info] 1847#1847 controller started
2019/11/06 09:37:38 [notice] 1845#1845 process 1846 exited with code 0
2019/11/06 09:37:38 [info] 1848#1848 router started
2019/11/06 09:37:38 [info] 1850#1850 "test" application started
ruby version: 2.6.3
{
"listeners": {
"*:3000": {
"pass": "applications/football"
},
},
"applications": {
"football": {
"type": "ruby",
"processes": 2,
"user": "deploy",
"working_directory": "/home/deploy/football/current/",
"script": "config.ru",
"environment": {
"RAILS_ENV": "production"
}
}
}
}
uninitialized constant RUBY_DESCRIPTION
that's all googled; opal/opal/corelib/constants.rb RUBY_DESCRIPTION = "opal #{RUBY_ENGINE_VERSION} (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION})" https://docs.ruby-lang.org/ja/latest/method/Object/c/RUBY_DESCRIPTION.html
2019/11/06 16:56:57 [info] 1772#1772 discovery started
2019/11/06 16:56:57 [notice] 1772#1772 module: ruby 2.6.3 "/usr/local/modules/ruby.unit.so"
2019/11/06 16:56:57 [info] 1773#1773 controller started
2019/11/06 16:56:57 [notice] 1771#1771 process 1772 exited with code 0
2019/11/06 16:56:57 [info] 1774#1774 router started
2019/11/06 16:56:57 [info] 1776#1776 "test" application started
2019/11/06 16:57:20 [info] 1784#1784 "football" application started
2019/11/06 16:57:20 [alert] 1784#1784 Ruby: Failed to parse rack script
2019/11/06 16:57:20 [alert] 1784#1784 Ruby: /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant': uninitialized constant RUBY_DESCRIPTION (NameError)
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `rescue in load_missing_constant'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/nokogiri-1.10.5/lib/nokogiri/version.rb:54:in `to_hash'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/nokogiri-1.10.5/lib/nokogiri/version.rb:100:in `<module:Nokogiri>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/nokogiri-1.10.5/lib/nokogiri/version.rb:1:in `<main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/nokogiri-1.10.5/lib/nokogiri.rb:34:in `<main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/actiontext-6.0.0/lib/action_text.rb:6:in `<main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/actiontext-6.0.0/lib/action_text/engine.rb:8:in `<main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/all.rb:21:in `block in <main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/all.rb:19:in `each'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/railties-6.0.0/lib/rails/all.rb:19:in `<main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/releases/20191104053716/config/application.rb:3:in `<top (required)>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/releases/20191104053716/config/environment.rb:2:in `require_relative'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/releases/20191104053716/config/environment.rb:2:in `<top (required)>'
2019/11/06 16:57:20 [alert] 1784#1784 from config.ru:3:in `require_relative'
2019/11/06 16:57:20 [alert] 1784#1784 from config.ru:3:in `block in <main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
2019/11/06 16:57:20 [alert] 1784#1784 from config.ru:in `new'
2019/11/06 16:57:20 [alert] 1784#1784 from config.ru:in `<main>'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:49:in `eval'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:49:in `new_from_string'
2019/11/06 16:57:20 [alert] 1784#1784 from /home/deploy/football/shared/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:40:in `parse_file'
2019/11/06 16:57:21 [notice] 1771#1771 process 1784 exited with code 1
2019/11/06 16:57:21 [warn] 1774#1774 failed to start application "football"
2019/11/06 16:57:21 [alert] 1774#1774 failed to apply new conf
Hello,
There was the change in ruby 2.6 which moves RUBY_DESCRIPTION
global constant definition out of Init_version()
. Unit incorrectly initialises ruby this why constant is not defined. Please apply following patch for Unit and rebuild ruby module:
diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c
--- a/src/ruby/nxt_ruby.c
+++ b/src/ruby/nxt_ruby.c
@@ -85,14 +85,15 @@ static nxt_int_t
nxt_ruby_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
{
int state, rc;
- VALUE dummy, res;
+ VALUE res;
nxt_unit_ctx_t *unit_ctx;
nxt_unit_init_t ruby_unit_init;
nxt_ruby_rack_init_t rack_init;
+ char *argv[2] = { (char *) "NGINX_Unit", (char *) "-e0" };
+ RUBY_INIT_STACK
ruby_init();
- Init_stack(&dummy);
- ruby_init_loadpath();
+ ruby_options(2, argv);
ruby_script("NGINX_Unit");
rack_init.task = task;
@@ -707,7 +708,8 @@ nxt_ruby_rack_result_body(VALUE result)
}
} else if (rb_respond_to(body, rb_intern("each"))) {
- rb_iterate(rb_each, body, nxt_ruby_rack_result_body_each, 0);
+ rb_block_call(body, rb_intern("each"), 0, 0,
+ nxt_ruby_rack_result_body_each, 0);
} else {
nxt_unit_req_error(nxt_ruby_run_ctx.req,
/home/deploy/test_config.ru:
deploy@userv2 ~> nano config.json
deploy@userv2 ~> sudo curl -X PUT -d @config.json --unix-socket /var/run/control.unit.sock http://localhost/config
{ "success": "Reconfiguration done." }
root@userv2:/home/deploy# curl -I krsz.ru:3001 HTTP/1.1 200 OK Content-Type: text/html Server: Unit/1.12.0 Date: Sat, 12 Oct 2019 05:53:26 GMT Transfer-Encoding: chunked
add rails app to config.json/applications
deploy@userv2 ~> sudo curl -X PUT -d @config.json --unix-socket /var/run/control.unit.sock http://localhost/config
{ "error": "Failed to apply new configuration." }
deploy@userv2 ~> sudo cat /var/log/unit.logdeploy@userv2 ~> ruby -v ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] deploy@userv2 ~> rbenv -v rbenv 1.1.2-2-g4e92322
deploy@userv2 ~> sudo ruby -v ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux-gnu] deploy@userv2 ~> sudo rbenv -v sudo: rbenv: command not found
deploy@userv2 ~> sudo su root@userv2:/home/deploy# ruby -v ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] root@userv2:/home/deploy# rbenv -v rbenv 1.1.2-4-g577f046
deploy@userv2:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.3 LTS Release: 18.04 Codename: bionic
why app start for root ruby only?
i uninstall ruby
and now this error: