Running rake task from within war file

前端 未结 2 522
半阙折子戏
半阙折子戏 2021-01-26 15:03

My code base initially was written in ruby. It had a rakefile.rb file to perform db migration. I later changed the whole thing to jruby for the ease of deployment

相关标签:
2条回答
  • 2021-01-26 15:53

    Finally found something that works.... i first tried

    java -jar lib/jruby-complete-1.6.7.jar -S rake db_migrate[1] 
    

    which was working fine on my personal machine but giving me something like the message below on production

    rake aborted!
    cannot load Java class com.mysql.jdbc.Driver
    
    Tasks: TOP => db_migrate
    (See full trace by running task with --trace)
    

    this was because i was using gems like sequel, logger etc inside my rake task.... i head those installed on my machine but not on production machine.... installing those gems on production was not an option.... so i installed the gems required in the rake task in a separate directory and converted it into a jar file( http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar)... this command finally worked...

    java -jar lib/jruby-complete-1.6.7.jar -rlib/mygems.jar -S rake db_migrate[1]
    

    point to note: no matter where you place the jar file, warbler 'll always send this to lib directory although you 'll still see a dummy jar file at the original location... i think the solution can be a bit neater if worked out in a couple of ways, although haven't tried this....

    i>by including the gem files in jruby-complete-1.6.7.jar itself as mentioned in the blog mentioned above...

    java -jar lib/jruby-complete-1.6.7.jar -S rake db_migrate[1]
    

    should work then...

    ii>by writing some kind of a manifest file and include it in the mygems.jar to make this run independently... if this happens

    java -jar myapp.jar -S rake db_migrate[1] 
    

    should work

    0 讨论(0)
  • 2021-01-26 15:56

    this seems not yet supported by warbler - executing jruby style commads works with an executable .jar but making a .war executable only allows it to run with an embed web server ... nothing else.

    0 讨论(0)
提交回复
热议问题