I want to start Puma (v.5.2.2) using SSL in on Windows on Rails 6.
When I execute:
bundle exec puma
I get the following error:
Puma compiled without SSL support (RuntimeError)
I have openssl installed:
>openssl version
OpenSSL 1.1.1j 16 Feb 2021
In the file puma.rb, I inserted:
ssl_bind '0.0.0.0', 3000, {
key: 'mykey.key',
cert: 'mykey.crt',
verify_mode: 'none'
}
I generated mykey.key and mykey.crt and put them in Rails root folder.
What I've already tried, without success:
I reinstalled Puma after the installation of openssl
I ran the server using this command: rails s -b "ssl://localhost:3000?key=mykey.key&cert=mykey.crt"
I tried Puma version 4.x.x
> ruby -rpuma -e "puts Puma.ssl?"
false
gem install puma
> ruby -rpuma -e "puts Puma.ssl?"
true
Related
I just updated from MacOS 12.x to 13.0.1
Starting a Rails app with
➜ rails s
works fine
=> Booting Puma
=> Rails 5.2.8.1 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.6 (ruby 2.6.6-p146), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
But when I try with
➜ rails s -d
Output stops at
=> Booting Puma
=> Rails 5.2.8.1 application starting in development
=> Run `rails server -h` for more startup options
And no server is started
➜ ps -ef | grep puma
501 69877 51917 0 6:45 ttys000 0:00.00 grep puma
➜ ps -ef | grep rails
501 72493 51917 0 6:49 ttys000 0:00.00 grep rails
Well, I found a workaround. This is by no means perfect but if it helps anyone with the same problem:
nohup rails s </dev/null >/dev/null 2>&1 &
The & at the end will make it run in the background. All output/input goes to/from /dev/null and nohup makes sure it will run even after you quit the session.
The reason has nothing to do with the fact that you updated to MacOS Ventura.
Puma daemonization has been removed without replacement since version 5.0.0, and it has been extracted to the puma-daemon gem, which currently works only with Puma version ~> 5.
Therefore now you have two ways to make it work: with puma-daemon, or put it in no hanghup background mode.
METHOD 1: USING PUMA DAEMON GEM
bundle add puma-daemon
Add these line to your application’s Gemfile:
gem 'puma-daemon', require: false
gem 'puma', '~> 5'
Add these lines to config/puma.rb:
require 'puma/daemon'
daemonize
and ensure you have set up at least one worker (workers 1)
Now you should be able to run puma webserver as a daemon with rails server (please notice that you must remove any -d or --daemonize from the command line)
PUT IT IN NO HANGHUP BACKGROUND MODE
Just run rails server --no-log-to-stdout & to put the server in background and stop the output, and enclose it in a nohup >/dev/null command to get rid of the nohup.log file:
nohup rails server --no-log-to-stdout >/dev/null &
This method works with any Puma version and doesn't require the gem.
Don't mess around with the two ways.
I have just installed devise on my Ruby on Rails project, it worked perfect on localhost, but when i did the same on Live Server then it started throwing me following error:
undefined method `devise_for' for #<ActionDispatch::Routing::Mapper:0x007facfbc96e18>
i have already restarted the Nginx server by using this command:
sudo /etc/init.d/nginx restart
but no effect.
Thanks.
Note:
Rails version is Rails 4.2.7.1
Ruby version is ruby 2.2.4p230
Aha! finally...
I just stop and start the puma and it's started working. I ran the following commands:
ps aux | grep puma
kill -s SIGUSR2 17562
bundle exec puma -e development -d -b unix:///home/democraticags/digitalammo/shared/sockets/puma.sock
Anyways thanks to all of you who devoted their precious time :)
I am trying to run my rails application using Puma over ssl in Windows ServerR2. I followed an answer of this question. I have installed puma with the SSL directory and I run puma using
>puma -b 'ssl://127.0.0.1:3000?cert=C:\Sites\server.crt&&key=C:Sites\server.key' -e development -S puma -C config\puma.rb
Also, I have created the cert and key, using this link. But I get the error
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-2.15.3/lib/puma/binder.rb:131:in `check': SSL not available in this build (StandardError)
works great in rails 5.2.3 and puma 3.12
gem uninst puma
ridk exec pacman -S mingw-w64-x86_64-openssl
gem inst puma
I have an Ubuntu 14.04 server with nginx and unicorn. I have deployed a Rails application with capistrano to /home/rails/myapp.
When trying to restart unicorn with sudo service unicorn restart I get the following:
* Restarting Unicorn web server unicorn
rack not available, functionality reduced
rack and Rack::Builder must be available for processing config.ru
I'm getting a 502 from nginx when trying to access the site in my browser.
Here's my /etc/default/unicorn file:
# Change paramentres below to appropriate values and set CONFIGURED to yes.
CONFIGURED=yes
# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60
# Path to your web application, sh'ld be also set in server's config.rb,
# option "working_directory". Rack's config.ru is located here.
APP_ROOT=/home/rails/myapp/current
# Server's config.rb, it's not a rack's config.ru
CONFIG_RB=/etc/unicorn.conf
# Where to store PID, sh'ld be also set in server's config.rb, option "pid".
PID=/home/rails/myapp/current/pids/unicorn.pid
RAILS_ENV="production"
UNICORN_OPTS="-D -c $CONFIG_RB -E $RAILS_ENV"
PATH=/usr/local/rvm/rubies/ruby-2.3.0/bin:/usr/local/sbin:/usr/bin:/bin:/sbin:/usr/local/rvm/bin:/usr/local/rvm/gems/ruby-2.3.0#global/bin:/usr/local/rvm/gems/ruby-2.3.0/bin/
export GEM_HOME=/usr/local/rvm/gems/ruby-2.3.0
export GEM_PATH=/usr/local/rvm/gems/ruby-2.3.0:/usr/local/rvm/gems/ruby-2.3.0#global
DAEMON=/usr/local/rvm/gems/ruby-2.3.0/wrappers/unicorn
Here's my /etc/unicorn.conf file:
listen "unix:/var/run/unicorn.sock"
worker_processes 4
user "rails"
working_directory "/home/rails/myapp/current"
pid "/var/run/unicorn.pid"
stderr_path "/var/log/unicorn/unicorn.log"
stdout_path "/var/log/unicorn/unicorn.log"
Any Ideas? I feel like I have tried everything.
Try running the following before starting unicorn:
gem install rack
If your RUBY VERSION is <= 2.2.2
then run the following commands:
gem install rubygems-update
update_rubygems
then run: gem install rack and it will display the version supported that you should be installing.
Hi i switched my Ruby on Rails development platform from Windows 7 to Linux (Debian), I copied entire app directory to Linux and run bundle installand the command was successful. Than i run rake db:migrate and it quit with following error:
`mri_21` is not a valid platform. The available options are: [:ruby, :ruby_18, :ruby_19, :mri, :mri_18, :mri_19, :rbx, :jruby, :mswin, :mingw, :mingw_18, :mingw_19]
Than i Googled for the error and found this, i followed the suggested steps, i.e.:
gem update bundler
above command output:
Updating installed gems
Nothing to update
Than: bundle install and this was also successful.
But still getting same error on rake db:migrate
my ruby version: ruby 1.9.3p194
unable to get rails version by rails -v getting the same mri_21 error but in my app's Gemfile i have gem 'rails', '4.1.5'
EDIT: But when i tried bundle exec rake db:migrate it was successful. and than i run bundle exec rails s and app running successfully :
=> Booting Thin
=> Rails 4.1.5 application starting in development on 0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Now my question is, how to get rid of this bundle exec every time, and what's going on with this.
Since bundle exec just fixes the PATH, and GEM_PATH variables, you should have all the gem binaries in the PATH variable before that are specified to wrong versions of rails, and gems. Also set GEM_PATH properly. So you be able to avoid the bundle exec call. All the values you are able to know with calls:
$ bundle exec echo GEM_HOME=$GEM_HOME\; GEM_PATH=$GEM_PATH\; PATH=$PATH
GEM_HOME=/home/malo/.rvm/gems/ruby-2.1.4; GEM_PATH=/home/malo/.rvm/gems/ruby-2.1.4:/home/malo/.rvm/gems/ruby-2.1.4#global; PATH=/home/malo/.rvm/gems/ruby-2.1.4/bin:/home/malo/.rvm/gems/ruby-2.1.4#global/bin:/home/malo/.rvm/rubies/ruby-2.1.4/bin:/home/malo/.rvm/bin:/usr/local/heroku/bin:/home/malo/.rbenv/bin:/home/malo/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/games:/usr/lib/qt4/bin