用于 Java 的 Capistrano?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/183091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Capistrano for Java?
提问by Teflon Ted
I'm a big fan of Capistrano but I need to develop an automated deployment script for a Java-only shop. I've looked at Ant and Maven and they don't seem to be well geared towards remote administration the way Capistrano is - they seem much more focused on simply building and packaging applications. Is there a better tool out there?
我是 Capistrano 的忠实粉丝,但我需要为仅使用 Java 的商店开发自动部署脚本。我看过 Ant 和 Maven,它们似乎不像 Capistrano 那样适合远程管理——它们似乎更专注于简单地构建和打包应用程序。有没有更好的工具?
采纳答案by Horst Gutmann
I don't think there is a Capistrano-like application for Java Web Applications, but that shouldn't really keep you from using it (or alternatives like Fabric) to deploy your applications. As you've already said, Ant is more a replacement for GNU Make while Maven is primary a buildout/dependency-management application.
我认为 Java Web 应用程序没有类似 Capistrano 的应用程序,但这不应该真正阻止您使用它(或像 Fabric 这样的替代品)来部署您的应用程序。正如您已经说过的,Ant 更像是 GNU Make 的替代品,而 Maven 主要是一个构建/依赖项管理应用程序。
Since Java Web Applications are thanks to the .war container less dependent on external libraries, you can (depending on your application server) make deploying an application as easy as running a simple HTTP PUT-request.
由于 Java Web 应用程序得益于 .war 容器对外部库的依赖较少,因此您可以(取决于您的应用程序服务器)使部署应用程序像运行简单的 HTTP PUT 请求一样简单。
But if you require additional steps, Fabrichas worked very well for me so far and I assume that Capistrano also offers generic shell-command, put and get operations. So I wouldn't look for too long for an alternative if what you already have already works :-)
但是,如果您需要额外的步骤,到目前为止,Fabric对我来说效果很好,而且我认为 Capistrano 还提供通用的 shell-command、put 和 get 操作。因此,如果您已经拥有的东西已经奏效,我不会寻找太久的替代品:-)
回答by Remco Wendt
I think that controltier (see: http://controltier.org) is what you are looking for. Though controltier doesn't need to be exclusively used for Java deploys.
我认为 controltier(参见:http: //controltier.org)正是您要找的。虽然 controltier 不需要专门用于 Java 部署。
See this excerpt from the docs (see: control tier documentation):
请参阅文档中的摘录(请参阅:控制层文档):
Is ControlTier the same as Capistrano, Fabric, or Func?
In their most fundamental concepts, ControlTier, Capistrano, Fabric, and Func are similar tools. We'd definitely call Capistrano, Fabric, and Func basic Command Dispatching Frameworks.
However, ControlTier, by design, goes far beyond what these other tools provide. The automation libraries and the web-based tools that ControlTier provides are designed to let you build full automation systems ready for use by enterprise or large-scale web operations teams. There are also features like error-handling and centralized logging that just aren't in the scope of other command dispatching tools.
Also, Capistrano is a Ruby-based tool that is primarily focused on the needs of the Ruby on Rails community. ControlTier, while written in Java, doesn't require you to know Java to use it. In fact, you can use whatever scripting languages you are comfortable with (including ruby). ControlTier attempts to be as language and platform (Linux, Unix, Windows, etc..) neutral as possible.
ControlTier 是否与 Capistrano、Fabric 或 Func 相同?
在最基本的概念中,ControlTier、Capistrano、Fabric 和 Func 是类似的工具。我们肯定会称 Capistrano、Fabric 和 Func 为基本的命令调度框架。
然而,ControlTier 在设计上远远超出了这些其他工具所提供的范围。ControlTier 提供的自动化库和基于 Web 的工具旨在让您构建完整的自动化系统,供企业或大型 Web 运营团队使用。还有一些功能,如错误处理和集中式日志记录,这些功能不在其他命令调度工具的范围内。
此外,Capistrano 是一个基于 Ruby 的工具,主要关注 Ruby on Rails 社区的需求。ControlTier 虽然是用 Java 编写的,但不需要您了解 Java 即可使用它。事实上,您可以使用任何您熟悉的脚本语言(包括 ruby)。ControlTier 尝试尽可能保持语言和平台(Linux、Unix、Windows 等)中立。
回答by Remco Wendt
At my work we use Capistrano exclusively to deploy all of our Java applications. It is definitely possible.
在我的工作中,我们专门使用 Capistrano 来部署我们所有的 Java 应用程序。这绝对是可能的。
回答by Remco Wendt
I use a capistrano recipe for building dspace (a java webapp, which in turn uses maven) from source : Installing dspace using capistrano
我使用 capistrano 配方从源代码构建 dspace(一个 java webapp,它反过来使用 maven):使用 capistrano 安装 dspace
回答by u445908
Capistrano could deploy all the web basic application. Deployments for the different language are almost the same:
Capistrano 可以部署所有 Web 基本应用程序。不同语言的部署几乎相同:
- update code
- push the code to production server
- prepare the configuration files for this deployment
- restart server. (thin, nginx, tomcat)
- 更新代码
- 将代码推送到生产服务器
- 为此部署准备配置文件
- 重启服务器。(瘦,nginx,tomcat)
in my company, we use Capistrano to deploy java, Vuejs, php, ruby , python applications.
在我公司,我们使用 Capistrano 来部署 java、Vuejs、php、ruby、python 应用程序。
回答by Andrew Goodnough
What's interesting is that Capistrano's idea of a repo assumes that you're dealing with an SCM (Source Control Manager). The structure on the server and the associated versioning of the application works on the application source. This makes sense for an interpreted language.
有趣的是 Capistrano 的 repo 想法假设您正在处理 SCM(源代码控制管理器)。服务器上的结构和应用程序的相关版本控制适用于应用程序源。这对于解释型语言来说是有意义的。
In a compiled language like Java, though, the versioning and branching comes before deployment and by the the time the application is compiled and built, the source control system is already left behind and what results is a versioned jar or tar to contain the application. Typically this tarball (jar + config) is published to a Maven artifact repository like Nexus or Artifactory.
然而,在像 Java 这样的编译语言中,版本控制和分支在部署之前进行,到编译和构建应用程序时,源代码控制系统已经被抛在后面,结果是包含应用程序的版本化 jar 或 tar。通常,这个 tarball (jar + config) 被发布到一个 Maven 工件存储库,比如 Nexus 或 Artifactory。
Surprisingly, this artifact repo maps to the Capistrano repo just fine. In place of the SCM, we can treat this tarball as the SCM (the source to be versioned). With this in mind, I've implemented a Capistrano SCM plugin for Maven artifact repos. It's new but works pretty nicely.
令人惊讶的是,这个神器仓库映射到 Capistrano 仓库就好了。代替 SCM,我们可以将此 tarball 视为 SCM(要进行版本控制的源)。考虑到这一点,我为 Maven artifact repos实现了Capistrano SCM 插件。它是新的,但效果很好。
It unifies our Ruby and Java projects on one tool, and most importantly, it brings the power of Capistrano's SSHKit and rake to our Java projects.
它将我们的 Ruby 和 Java 项目统一在一个工具上,最重要的是,它为我们的 Java 项目带来了 Capistrano SSHKit 和 rake 的强大功能。

