I got help here:
http://devnet.jetbrains.com/message/5490676
It seems Rubymine can't parse such arguments, but a workaround is to do this with a Ruby script from Run/Debug Configurations
質問
I can use THIN with
bundle exec thin start --ssl --ssl-verify --ssl-key-file /private/etc/apache2/ssl/server.key --ssl-cert-file /private/etc/apache2/ssl/server.crt
It works in the console/terminal, perfectly
But when I try to append these options in rubymine under "Run/Debug Configurations" -> "Edit Script Arguments" I get:
/Users/jan/.rbenv/versions/1.9.3-p392/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/jan/RubymineProjects/myapp/script/rails server thin -b 0.0.0.0 -p 3000 -e development --ssl-verify --ssl-key-file /private/etc/apache2/ssl/server.key --ssl-cert-file /private/etc/apache2/ssl/server.crt
/Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:33:in `parse!': invalid option: --ssl-verify (OptionParser::InvalidOption)
from /Users/jan/.gem/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:283:in `parse_options'
from /Users/jan/.gem/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:180:in `options'
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:54:in `set_environment'
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:42:in `initialize'
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `new'
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from /Users/jan/RubymineProjects/myapp/script/rails:6:in `require'
from /Users/jan/RubymineProjects/myapp/script/rails:6:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1 Can anyone help us / me out?
many thanks!
解決 2
I got help here:
http://devnet.jetbrains.com/message/5490676
It seems Rubymine can't parse such arguments, but a workaround is to do this with a Ruby script from Run/Debug Configurations
他のヒント
Use following way
require 'rack'
SERVER_KEY = File.expand_path('../../ssl-cert/host.key', __FILE__)
SERVER_PEM = File.expand_path('../../ssl-cert/host.crt', __FILE__)
# Thin SSL workaround
module Rack
module Handler
class Thin
def self.run(app, options={})
app = Rack::Chunked.new(Rack::ContentLength.new(app))
server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
options[:Port] || 3000,
app)
server.ssl = true
server.ssl_options = {
:private_key_file => SERVER_KEY,
:cert_chain_file => SERVER_PEM
}
yield server if block_given?
server.start
end
end
end
end
# Workaround end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
The option --ssl-verify
should not be used
Apparently this can actually be pulled off by adding a Procfile and the gem foreman, as in this set of instructions:
Using Rails, Thin and SSL in RubyMine: The solution!
Basically, you add foreman to your Gemfile:
gem 'foreman'
Then create a Procfile
(the link misspells this) in your root containing this:
web: thin start --ssl
or, to bind to 0.0.0.0 as RubyMine usually does:
web: thin start -a 0.0.0.0 -p 3001 --ssl
I did not need to specify the location of my ssl files, but if you wanted to it would be:
web: thin start -a 0.0.0.0 -p 3001 --ssl --ssl-key-file /private/etc/apache2/ssl/server.key --ssl-cert-file /private/etc/apache2/ssl/server.crt
I would not recommend using --ssl-verify
because that did not work for me.
Last, in RubyMine, create a new Ruby Configuration with the following attributes:
~/.rvm/gems/ruby-2.3.0@gemset/gems/foreman-0.82.0/bin/foreman
start
~/Sites/appname
In the Bundler tab, check the only checkbox to use bundle exec
when running it.
Last, in the logs tab, add a new log file pointing to ~/Sites/appname/logs/development.log