changing to jruby, get RuntimeError: Server handler (thin) not found - sinatra

My app works fine in MRI 1.9.2-p290 and 1.9.3-p125, but when I change to jruby-1.7.0-preview1 I get the error discribed. Here's the full error:
RuntimeError: Server handler (thin) not found.
detect_rack_handler at /home/qry_dev/.rvm/gems/jruby-1.7.0.preview1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1402
run! at /home/qry_dev/.rvm/gems/jruby-1.7.0.preview1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1293
(root) at /home/qry_dev/Ruby/query_engine/query_webserver.rb:320
load at org/jruby/RubyKernel.java:1017
(root) at -e:1
(I tried jruby-1.6.6 already, same error.)
The sinatra and thin gems (among others) are already installed. In fact, other than jruby instead of mri, everything's the same.
Any ideas? I've searched the web and seen this error, but it's usually for 3rd party tools, and nothing seems to apply.
EDIT: also tried installing thin (which I never had to do before) to linux itself via
sudo apt-get install thin
but still getting same error.

sinatra 1.3.2 (by default) checks only for mostly MRI compatible servers, see:
https://github.com/sinatra/sinatra/blob/e111243e813ede1f0f4c6918d9a8cc029e776fc3/lib/sinatra/base.rb#L1514
thin, mongrel do not work on JRuby due native C code (although there's effort to make them use some "native" Java code on JRuby)
you have two options either adjust the set server while on JRuby e.g. something like:
set :server, %w[trinidad webrick] if defined?(JRUBY_VERSION)
or rackup your application with the given handler rackup -s trinidad
do not forget to gem install trinidad first (under JRuby)

You can install thin server which sinatra will pickup automatically.
To install thin you can execute the following command
gem install thin

Related

Variant Effect Predictor | DBD mysql failing to setup

I trying to get set up with Variant Effect Predictor (VEP) on the command line. I'm following the setup tutorial but I'm encountering some errors around dependencies. I'm also quite new to the command line so if anyone is able to break down the solution too then I'd be very grateful. Thanks!
Tutorial: https://www.ensembl.org/info/docs/tools/vep/script/vep_tutorial.html
VEP requirements: http://www.ensembl.org/info/docs/tools/vep/script/vep_download.html#requirements
I also have Perl v5.32.1.
What I've done:
I installed dependencies (listed in the requirements page) with the following commands:
- sudo -s cpanm DBI
- sudo -s cpanm Archive::Zip
- sudo -s cpanm DBD::mysql
For DBD:mysql, I got the follwoing message:
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz ... OK
Configuring DBD-mysql-4.050 ... N/A
! Configure failed for DBD-mysql-4.050. See /root/.cpanm/work/1626111140.5937/build.log for details.
Trying it out anyway, I ran perl INSTALL.pl (from the tutorial page) and got the message below. I would like VEP to run in online mode too if possible.
`WARNING: DBD::mysql module not found. VEP can only run in offline (--offline) mode without DBD::mysql installed
http://www.ensembl.org/info/docs/tools/vep/script/vep_download.html#requirements
Hello! This installer is configured to install v104 of the Ensembl API for use by the VEP.
It will not affect any existing installations of the Ensembl API that you may have.
It will also download and install cache files from Ensembl's FTP server.
Checking for installed versions of the Ensembl API...done
Setting up directories
Destination directory ./Bio already exists.
Do you want to overwrite it (if updating VEP this is probably OK) (y/n)? y
- fetching BioPerl
- unpacking ./Bio/tmp/release-1-6-924.zip
ERROR: Unable to unpack file ./Bio/tmp/release-1-6-924.zip without Archive::Extract or tar/unzip/gzip`
You show us this error:
Configure failed for DBD-mysql-4.050. See /root/.cpanm/work/1626111140.5937/build.log for details.
So looking in there will give you more clues about what the problems are. Without that, we can only guess.
But we can make educated guesses. The DBD::mysql distribution comes with a file called DBD::mysql::INSTALL which will talk you through some of the problems you'll find while installing this module.
It's important to note that DBD::mysql is a wrapper around MySQL's client libraries. They are written in C, so you'll need a C compiler installed in order to build DBD::mysql. You'll also need the client libraries and the development versions of the client libraries (for the C header files that you'll need to compile the module). On Ubuntu, those packages are called "libmysqlclient" and "libmysqlclient-dev". If you don't have a C compiler, then you'll want to install "gcc" too.
But this is all getting a bit complicated. There's another, simpler, approach. If you're using the system version of Perl (the version that was installed as part of the operating system and probably lives in /usr/bin/perl) then I'd recommend using the pre-build Ubuntu version of the package, which you can install by running:
$ sudo apt-get install libdbd-mysql-perl
Installing that version uses the OS's own package manager, and the package manager knows which other packages are needed in order for it to work - so it will install those as well.
People will probably complain that you're better off installing the modules from CPAN as it gives you more flexibility and allows you to use more up-to-date packages than the versions from your OS repos. And they're right. But, honestly, if you're a non-Perl programmer who just wants to get an application up and running, this is by far the simplest approach.
(But, as I said above, this is all guesswork as you haven't shared the most important errors with us.)

Installing PHP 7.0.0RC2 with mysqli on Raspberry Pi B

Last week I installed PHP 7.0.0RC2 on my Raspberry Pi B.
I am able to view PHP pages, however, the problem is that I cannot connect to the database using mysqli (I know that mysql is no longer supported in PHP v7).
I ran the ./configure command with --with-mysqli=shared.
However, when I check which modules are installed using the php -m command, I do not see mysqli.
I tried adding extension=mysqli.so to the php.ini file.
It first complained that the mysqli.so file could not be found, so I tried copying the mysqli.so of my php5 version to the extensions folder.
However, this did not solve the problem and resulted in the following error message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20141001/mysqli.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20141001/mysqli.so: undefined symbol: zval_used_for_init in Unknown on line 0
Does anyone got any suggestions of how to get mysqli to work with my PHP7 installation on my Raspberry Pi?
You may find detailed information in the configure output, but it's pretty hard to catch, and if it's not a fatal error, won't stop the build going ahead when you make.
The recommended (read: only decent) driver for MySQLi is the MySQL Native Driver (mysqlnd).
If you want MySQLi to be built shared, you must also build mysqlnd shared, and everything that depends on it (PDO MySQL, for example).
It's going to be simpler to just build the native drivers static, using the configure option:
--with-mysqli=mysqlnd
Which will enable a static build of mysqlnd and mysqli.
If for some reason you really do want to build shared, then you'll need configure options that closely resemble, if not are exactly the same as:
--enable-mysqlnd=shared
--with-mysqli=shared,mysqlnd
Which will result in a shared build of mysqlnd and mysqli, requiring you to add extension=mysqlnd.so and extension=mysqli.so in the appropriate order (the latter depends on the former), in the appropriate place.
Remember to make distclean before you re-configure the build, surprising things will happen if you do not ;)

Deploying meteor app to a webserver

Does anyone know a step by step guide to deploy the own meteor app from windows to a webspace (not xxx.meteor.com).
I've found some tools like meteor.sh, but I'm a beginner and it's difficult without a guidance and without linux (needed to execute sh-files for example)
Make your project locally
Build your project locally, you could test it using meteor run or even meteor deploy xxx.meteor.com to see if its working
Bundle your app
Use meteor bundle deploy.tar.gz to make a file called deploy.tar.gz in your meteor directory containing your project
Upload your file to your server
This depends more on how your server is/what your platform is but you can use a tool to upload it for you (e.g Transmit on mac)
Install node.js & fibers on your platform if you don't have it already
This depends alot on your server platform. Have a look at http://nodejs.org/ for more detailed instructions
Extract your bundle
If on a *nix platform you could do the below in the directory where you uploaded your bundle (explanation):
tar -xzvf bundle.tar.gz
Enter the directory and install fibers
Fibers is needed for any meteor project, it helps use synchronous style code on server side javascript:
cd bundle/programs/server/node_modules
rm -r fibers
npm install fibers#1.0.1
The first line enters the directory in your bundle where fibers is installed, the second removes it, and the third reinstalls it.
Get MongoDB on another server or use a third party service like mongohq
Meteor production deployments need another mongodb. You can either install it on another server or use a third party server. It's not recommended to install it on the same server you install meteor on.
Finally check if your project is runnable
cd ../../../
node MONGO_URL=mongodb://dbuser:dbpassword#dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js
The first line gets you back to the bundle directory and the second runs node.js on your project with the parameters that let you connect to your mongodb database.
Install something to let it run in the background
It depends on which one you want to use, foreverjs is quite easy to use
npm install forever -g
If you get an error problem try using sudo before the npm (which lets you run as a super user).
Then you can run forever:
forever start MONGO_URL=mongodb://dbuser:dbpassword#dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js
And its done!
Extra notes
While its not that easy to get started from scratch this should help you get started. You still need to secure your mongodb server up if you've used your own servers.
The meteor.sh script does pretty much the same as above but very quickly if you learn to use that instead it might be faster to deploy updates
You might not have wget or a couple of commands that you might need that come up and give you Unknown command errors. Have a go at running yum or apt-get and see which one of the two you might have. You can then install the required package using one of these installer tools, i.e with yum install wget
I hope this helps you, its not that easy to deploy to a server on the first shot as a couple of things might be missing (files/packages/dependencies), you might run into other problems with permissions & stuff, but you could always ask on serverfault or here on stackoverflow on what you run into.
I recommend Meteoric.
Note, that you need to run meteoric from your development machine.
Script is self explanatory and works perfect for me.

Ruby 1.9.1 Installation on Debian

Currently having a bit of a nightmare trying to run code on another machine. I've been developing a Sinatra app as part of an internship I'm doing. I'm developing on an Ubuntu 12.04 machine, with ruby1.9.3 (through RVM). My supervisor wants to run it on his Debian Squeeze machine, the development server. I listed all the necessary gems in the Gemfile, and pushed up the initial commit. However, we just can't seem to get it running on the Debian box.
Ruby1.8 was initially installed, before my supervisor was aware we'd need Ruby1.9 and up. The Ruby1.9.1-full debian package was installed, but trying to run the Sinatra app with the ruby1.9.1 application.rb does nothing. I added in some print statements to debug it, and the ruby interpreter is reaching the end of the file - the problem is that it is not starting up WEBrick. This exact same code has no problem running on my machine, why is it being so problematic on Debian?
NOTE: Don't suggest switching to RVM. My supervisor is adamant we only use official packages, so it's beyond my control.
I have my Sinatra apps configured a bit differently. That is, I don't run them with ruby application.rb, rather I have a config.ru file with instructions to the Rack middleware. When I want to run my app i just run rackup and the server will start.
The minimal example layout as shown in the Sinatra Readme is as follows.
A basic Sinatra application.rb file:
require 'sinatra'
get '/' do
'Hello world!'
end
and the config.ru:
require './application'
run Sinatra::Application
I don't really know if or how this would make a difference in your situation, but it was the first thing that sprung to mind.
P.S.
Now that I think of it, another thing you could try is to use another server than WEBrick. I think if you add
gem 'thin'
to your Gemfile it should automatically use Thin instead. Remember to re-run bundle install first.

REE rake gems:install is not working correct

I've installed REE on CentOS 5 for a very special task (using rails 2.3.10 and ruby 1.8) and I really need it to be isolated
In this case I won't use bundler or smth so.
Everything works ok if I'll setup every gem manually via
/opt/ree/bin/gem install agem
But when I run
/opt/ree/bin/rake gems:install
in prepared for this command project - all (or most, I haven't check every dependency) gems are installed via /usr/bin/gem into common gem path, where I do not need any of them
This is an issue and I do not want to install all gems manually. Have smb ever hit into this issue and probably knows solution?
Solution that really helped me was to temporarily replace /usr/bin/gem with a symbolic link to /opt/ree/bin/gem
With this replacement /opt/ree/bin/rake gems:intall worked as expected - all required gems were installed to REE path - returning /usr/bin/gem to original gem executable made system stable again
This is not very clean solution but it works, so it can be used like hammer in critical situation.
There's either a GEM_HOME variable somewhere in the environment, or the runtime ruby called is not ree. Therefore, I'd suggest at least 3 things to try:
Start with an almost empty environment (run env -i sh for example) and run again the rake command, see if this is still installs gems in the common gem path. Be careful, because env -i is an empty environment, you might see complaints from rubygems (because no HOME or nothing else is set)...
Check that the shebang line (first line of the rake program) really indicates your REE binary and not something else
Finally, do run rake using the REE binary with /opt/ree/bin/ruby /opt/ree/bin/rake gems:install
This should give you an indication of what's going wrong. All in all, I think that the environment issue is probably the most probable culprit of this thing