Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building a deployable and self-executable WAR file of Squash #57

Closed
wants to merge 8 commits into from

Conversation

bjeanes
Copy link
Contributor

@bjeanes bjeanes commented Mar 4, 2013

Work:

@@ -3,3 +3,6 @@
node_modules
doc/fdoc-html
tmp/cache/*
*.war
public/assets
bin/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to (eventually) account for bundling with --binstubs such that you can run any gem command from the WAR file by doing (for example): java -jar squash.war -S rails console. See jruby/warbler#136

@bjeanes bjeanes mentioned this pull request Mar 6, 2013
@bjeanes
Copy link
Contributor Author

bjeanes commented Mar 11, 2013

@RISCfuture do you have any input for how you think configuration should be handled with the constraint of being able to be provided post-compilation?

I'm currently thinking that an initializer that can add an extra Configoro directory based on an environment variable and it will merge those in after all other configs have loaded. Therefore, something like CONFIG_DIR=/var/my-app/config java -jar my-app.jar could be used and I can manage those configs separately from the app repository and build process.

@RISCfuture
Copy link
Contributor

I authored the Configoro gem so I'm happy to add runtime configuration directory support if that's the ideal way of doing it. Might be better than polluting the namespace with 100 environment variables.

@bjeanes
Copy link
Contributor Author

bjeanes commented Mar 11, 2013

Yeah I'd like to avoid that too. The simplest solutions are:

  • adding extra directories at runtime, which should be doable with something like:

    Dir["#{ENV["CONFIG_DIR"]}/*.yml"].each { |f| Squash::Configuration << f }
  • adding ERB interpolation a la Rails to allow users to use ENV vars directly, if they chose:

    database:
      production:
        username: <%= ENV["DB_USER"] %>
        #...

@RISCfuture
Copy link
Contributor

I'd prefer the former approach as it allows the app to continue to work for people who do not wish to use ENV-based configuration.

@bjeanes
Copy link
Contributor Author

bjeanes commented Mar 12, 2013

Actually, both options should allow config as it exists today. In the latter case, it would simply let users interpolate values into their database.yml using ERB and draw the real values from any source (ENV is just an example, Java properties or shelling out are others). This is exactly how database.yml in Rails works today. All that is added is an ERB call between reading the file and parsing the yml. See here for how Rails does it: https://github.com/rails/rails/blob/9ee6f3cc8/railties/lib/rails/application/configuration.rb#L106

@bjeanes
Copy link
Contributor Author

bjeanes commented Mar 12, 2013

I'd actually vote for doing both of these things. Making Configoro more versatile and inline with Rails' regular .yml files, may have other positive outcomes too. Adding the extra directory means config can be kept in a separate location/repository, which is a major win because it means not having to fork Squash in anyway and allows keeping up to date frictionless.

The only ugly duckling here is database.yml, since Configoro does not control this. I think going with the Rails standard of checking in database.example.yml and git ignoring database.yml solves this for the most part, though.

Bo Jeanes added 8 commits March 12, 2013 10:58
Thanks to jruby/warbler#141, this will allow us to do the following in
order to start a console, run a rake task, etc. directly from the WAR
file:

    java -jar squash.war -S script/rails console
`setup.rb` can still be used to generate a working database.yml but
local changes to this file won't result in a dirty directory
# :development. The gemspec requires warbler/version which doesn't
# exist so the whole thing blows up. Putting this in :default group
# until I can figure out how to fix it.
gem 'warbler', github: 'bjeanes/warbler', platform: :jruby, require: nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Squash uses JRuby at Square but we don't need Warbler; no reason we should have to install the gem. I'm facing a similar issue with Resque integration -- how can I avoid bundling the Resque gems for installs that don't use Resque? Bundler has no concept of an "optional" gem.

I need to come up with a comprehensive solution to this problem before we integrate too many optional third-party tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes a lot of sense. I'll think about it too. If I were in your position, I would investigate what it would take to make Squash a Rails engine such that people can simply include it as a gem into their own mostly empty Rails app and set up customizations from there. I'm going to investigate vendoring Square and mounting the Rails app into a small Rack app as is...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah there were a lot of suggestions about making Squash some kind of giant gem that gets included into an otherwise empty app, but I think that kinda obfuscates the implementation a bit and disincentivizes contribution to the web app.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, the most recent commits added a decent (but not awesome) functionality for optional gems. Check it out!

@karthick086
Copy link

what is squash basic and dtd on xml pls sent me

@kirantpatil
Copy link

@bjeanes may I know about rails engine support work for squash? We were also thinking in the same line. Have you done anything so far ?

Thanks.

@bjeanes bjeanes closed this Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants