Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Remove dependencies on Thin, so Dashing can run on JRuby. #427

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

headius
Copy link

@headius headius commented Aug 17, 2014

Here's a quick pass to remove the dependency on Thin (and EventMachine) in favor of Puma. This allows dashing to work on JRuby, and Puma is a great server.

I was confused about the connection-closing block that used Thin-specific APIs. We can discuss what that code is doing and how to do it under Puma.

@headius
Copy link
Author

headius commented Aug 17, 2014

Relates to #417, obviously :-)

@headius
Copy link
Author

headius commented Aug 20, 2014

I now have a JRuby Dashboard running with this modified version of Dashing, released as dashing-jruby: http://jruby-dashboard.herokuapp.com/sample

Sure would be nice to make it standard dashing :-D

@ghost
Copy link

ghost commented Sep 19, 2014

Tried installing dashing-jruby and replacing in my Gemfile and config.ru, but I get the following error when running "dashing start":

/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.4/lib/bundler/rubygems_integration.rb:256:in block in replace_gem': thin is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /usr/bin/thin:22:in

'

Am I doing something wrong?

@headius
Copy link
Author

headius commented Sep 19, 2014

@Kevster Ahh "dashing start" must be trying to start thin directly. Will check.

@headius
Copy link
Author

headius commented Sep 19, 2014

Ahh yes, dashing start/stop require that the server be able to daemonize, which can't be done through usual Ruby mechanisms on JRuby. I'm looking at doing something with nohup instead.

@headius
Copy link
Author

headius commented Sep 19, 2014

I've pushed an additional change that removes "stop" and makes "start" use puma. Because there's no daemonizing on JRuby, start just launches the server and waits for it. I did not rig up something with nohup since it wouldn't work on e.g. Windows (not sure if that's a concern, since I don't think thin/em were reliable on Windows).

I'm pushing dashing-jruby 1.3.4.1 with this change.

@ghost
Copy link

ghost commented Sep 25, 2014

Great, works like a charm! By the way, noticed you're using heroku. Did you specify a Procfile for using dashing-jruby (and puma)?

@headius
Copy link
Author

headius commented Sep 25, 2014

I didn't do anything special. The https://github.com/jruby/jruby-dashboard repository is everything.

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = 'dashing'
s.name = 'dashing-jruby'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no sense on put that line on the commit of your PR.
Because if it would merged, you would change the gemspec of the entire project to dashing-jruby.
I think you just want to fork that project, and on your fork only, put these line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the project should remain available as the gem dashing.

However, the remainder of this PR has merit and could be considered. I have no allegiances to Thin.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cefigueiredo I opened this PR as a good faith attempt to work with you to make Dashing work on JRuby. I assumed the PR will evolve as we discuss its changes and find the best way to replace Thin with Puma. If you prefer to only receive fully-formed PRs before discussing them, I will try to do that in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That certainly is not what I am saying... My intent in commenting was to re-spark discussion around this. There are other issues that may be resolved by moving to Puma, so I think this is good even without providing jruby compatibility.

But the gem isn't going to be renamed... People are going to type gem install dashing 👍

@jrcryer
Copy link

jrcryer commented Nov 14, 2014

👍 - it would be great to switch to puma for JRuby support

alias_method :stop_without_connection_closing, :stop
alias_method :stop, :stop_with_connection_closing
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this code doing? Is there a Puma equivalent?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not really sure about this :-\ It appears to monkey-patch Thin to close all open connections during shutdown. I don't think there needs to be an equivalent for Puma, because it already manages those connections and has a graceful shutdown path. Perhaps Thin would refuse to shut down unless all connections were closed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this seems weird. Maybe this is okay to remove...

I feel like Thin should already be managing those connections with a graceful shutdown path too...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the PR that introduced that change for some context: #383

I am aware that this is thing dependant, and I do want to take it out.

@headius
Copy link
Author

headius commented Jan 29, 2015

Sorry that I missed the replies in November...busy time for JRuby.

I've commented on the source comments you provided and I'm looking into ways to spawn puma rather than starting it as a blocking child process. I think the best option will be to use nohup and puma's management interface to spawn and manage the subprocess, but I don't know what the equivalent would be on Windows. I'm also not sure how important Windows support is, since it appears there hasn't been a Windows release of EventMachine since 2013.

@terraboops
Copy link
Contributor

Currently, Dashing can be run as a daemon with dashing start -d ... which is a tricky way of passing -d to thin.

It seems that Puma uses a different model, so I think pumactl needs to be used like this:
bundle exec pumactl -S /path/to/state.file restart

@headius
Copy link
Author

headius commented Jan 29, 2015

Right that is where I am at now. Demonization is complicated with JRuby because we can't fork, but the nohup approach plus state file should work well.

@MartynKeigher
Copy link

Well here is my awful workaround to complete the switch to puma ...

As my ubuntu server is a VM, i just to go the console and kick off sudo bundle exec puma there and just let it run. (doesn't affect my putty sessions then!) Totally 'OLD SKOOL'! ;p haha

@terraboops terraboops mentioned this pull request Feb 6, 2015
@terraboops
Copy link
Contributor

Not sure how everyone else feels about this PR, but I think it'd be a positive move once the tests are fixed up to reflect this change.

@terraboops
Copy link
Contributor

There are a number of requests for this in #183 -- seems like this should be merged after being fixed up.

@pushmatrix
Copy link
Member

I want to make this happen while remaining backwards compatible

@terraboops
Copy link
Contributor

I am going to take this over and get it up to code so we can merge it in, unless there are objections.

@MartynKeigher
Copy link

Yup! Go for it man! +1000

@ghost
Copy link

ghost commented Nov 18, 2015

Sounds great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants