(Rails、Warbler)在 Glassfish 中部署和初始化 Rails 应用程序?

发布于 2024-08-22 21:48:32 字数 489 浏览 5 评论 0原文

我在 SERVERFAULT 上发布了同样的内容,但没有得到回复。事情是这样的:

我目前正在完成一个 Rails 应用程序。我使用 Warbler 将其打包为“.war”文件,并使用 GlassFish 来部署它。我这样做是因为该应用程序将分发给公司供内部使用。可以说我可以/应该使用另一个框架来开发这种性质的应用程序,但是,我选择了开发的简易/速度而不是部署的麻烦。

也就是说,我的设置在我的开发机器上运行得相当好。但是,我很好奇如何自动化环境初始化。换句话说,我需要弄清楚如何确保所有数据库、文件等。在部署时配置。 到目前为止我看到的所有示例都假设您在要部署的系统上运行 IDE,并且让您在部署之前手动运行 rake 任务。但是,我需要简单地为最终用户提供“.war”,并能够在应用程序部署/启动时运行所有 rake 任务。

有人能指出我在这方面的正确方向吗? FWIW Glassfish 手册中没有任何关于环境初始化等的内容——话又说回来,我不认为我应该期望它们涵盖部署的每个方面。

最好的。

I posted this very same item on SERVERFAULT, but got no reply. So here goes:

I'm currently in the process of finishing up a Rails application. I am using Warbler to package it up as a ".war" file and am using GlassFish to deploy it. I do this because the application is to be distributed to companies for in-house use. Arguably i could/should have used another framework to develop an application of this nature, however, I chose ease/speed of development over deployment hassle.

That said, I've got the setup working reasonably well on my development machine. However, I'm curious as to how to go about automating environment initialization. In other words, I need to figure out how to ensure that all DBs, files,etc. are configured upon deployment.
All of the examples I've seen thus far assume you're running your IDE on the system to which you wish to deploy and they have you run your rake tasks manually before deployment. However I need to simply give the end user the ".war" and be able to run all rake tasks upon application deployment/launch.

Can someone point me in the right direction regarding this? FWIW there is nothing in the Glassfish manual about environment initialization etc. -- then again, I don't suppose I should expect them to cover every single aspect of deployment.

Best.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏已如深秋| 2024-08-29 21:48:32

根据您的数据库要求,您可以在 Glassfish 环境中嵌入 Derby。您可以轻松创建一个空白/默认数据库,然后将该干净版本放入您必须设置的每个 Glassfish 环境中。

我不确定您还需要配置和初始化什么,但我想说,如果可以的话,将其编写成脚本,或者使用一些 rake 任务。 Embedding Derby 负责数据库启动和初始化。请记住,war 文件只是一个 zip 文件,因此通过脚本添加配置文件应该不那么困难。您可以使用 Rails 初始化程序 (/config/initializers/) 加载 yml 文件以进行配置或应用程序启动时需要执行的任何操作。

您将无法让初始化程序在数据库中创建架构,但您可以让它们检查默认种子数据,如果不存在则将其放入。

您应该能够访问 Glassfish 和 JVM 可以访问的文件系统的任何部分。我对 Glassfish 了解不多,但我在 Tomcat 上使用 jruby Rails 应用程序时遇到的唯一问题与相对路径有关,相对于启动脚本的调用位置,而不总是相对于安装根目录。这可能可以通过 Tomcat 中正确的启动脚本或设置适当的启动文件夹来解决,我只是不需要深入研究这一点。

Depending on your database requirements you can embed Derby within the Glassfish environment. You can easily create a blank/default database and then put that clean version in each Glassfish environment you have to set up.

I'm not sure what else you need to configure and initialize, but I'd say that if you can, script it up, either with some rake tasks. Embedding Derby takes care of database startup and initialization. Remember that a war file is just a zip file, so adding config files via a script shouldn't be so hard. You can use rails initializers (/config/initializers/) to load up yml files for configuration or whatever you need to do as the app starts up.

You won't be able to have the intializers create the schema in the database, but you could have them check for default seed data and put it in if it isn't there.

You should be able to access any part of the file system that Glassfish and the JVM can access. I don't know much about Glassfish but the only problems I've had with jruby rails apps on Tomcat were related to relative paths being relative to where the startup script was called from, and not always relative to the installation root. This could probably be solved with the right startup scripts in Tomcat or setting the appropriate start-in folder, I just haven't had a need to dive in to that very much.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文