在詹金斯上持续部署基于OSGi的应用程序 [英] Continuous deployment of OSGi-based application on jenkins

查看:120
本文介绍了在詹金斯上持续部署基于OSGi的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

花了几个小时试图了解如何在基于 OSGi的应用程序中实现连续部署后,我终于提出了第一个问题stackoverflow,希望对我可能做错了什么或错过了做一些指示-某种程度上,我觉得自己走错了路...

After spending a couple of hours trying to understand how to make continuous deployment work in the case of an OSGi-based application, I am finally posing my first question on stackoverflow, hoping for some indications on what I might have done wrong or missed - somehow I feel being on the wrong track...

这是我要实现的目标:

  1. 构建一些捆绑包,然后将它们安装到Maven存储库(这里没有问题,使用bnd)

  1. build some bundles and install them to the maven repository (no problem here, using bnd)

现在拥有所有组成我的应用程序的捆绑软件(通过所有测试等),我想部署并运行该应用程序,也就是说,使用这些捆绑软件启动一些OSGi框架.

now having all the bundles making up my application (passing all tests and so on), I want to deploy and run the application, that is, start some OSGi framework using those bundles.

开始不是问题-"mvn pax:provision -Dframework = equinox"可以解决问题.我的应用程序启动了码头,因此很容易通过浏览器进行验证,以查看一切是否正常(除所有测试之外)

Starting is not the issue - "mvn pax:provision -Dframework=equinox" does the trick. My application starts jetty, so it is easy to verify via a browser to see if things look ok (additionally to all the tests)

但是,现在,尝试连续" ,下一次我想应用此过程时,我确实应该确保关闭正在运行的实例首先进入我的应用程序(至少释放正在使用的端口).因此,要重新运行,我必须以某种方式首先关闭旧安装.

But, now, trying being "continuous", the next time I want to apply this procedure, I really should make sure to shut down the running instance of my application first (releasing at least the port being used). So, to rerun everything, I somehow have to shut down the old installation first.

这是我的问题开始的地方:这有什么帮助我吗?我知道这里有 maven-deploy-plugin ,但这仅在将一些WAR/EAR文件部署到某些标准应用程序容器中时才有用(似乎不需要重新启动).

And this is where my question starts: Is there anything helping me with this? I understand there is the maven-deploy-plugin, but this only seems to be useful when deploying some WAR/EAR file into some standard application container (without the need of restarting it seems).

我真的只需要运行一些脚本来启动 OSGi环境-然后,下次,再次优雅地关闭,然后再次启动它.对于tomcat,jetty,jboss等,有一些 shutdown.sh 脚本或 mvn jetty:stop 指令,但是我真的必须自己编写此类脚本吗? ?这是我认为我开始走错路的地方,我想一定有人已经解决了这些问题;)

I really only need to run some script to start up the OSGi enviroment - and then, next time, to shut it down gracefully before I start it again. With tomcat, jetty, jboss and the like, there are some shutdown.sh scripts or mvn jetty:stop instructions, but do I really have to write those kind of scripts myself? This is where I think I am starting to be on the wrong track, somebody must have had those issues before me and solved them I guess ;)

我了解我可以以某种方式尝试使用 JMX 或使用 telnet控制台来访问正在运行的实例,以发出停止0"命令,但是此感觉不对.

I understood that I could somehow try to use JMX or use the telnet console to access the running instance to issue an "stop 0" command but this feels wrong.

从jenkins启动的进程应该编译/构建/部署项目,但我不能启动长期运行的线程,因此我必须以某种方式启动外部"进程,下次再次尝试时,我想先杀死它.

Processes started from jenkins should compile/build/deploy projects, but not start long-running threads I guess, so I somehow have to start some process "outside" which I want to kill first the next time I try it again.

有什么想法吗?也许我缺少什么?在此先感谢您的任何投入!

Any ideas? Maybe I am missing something? Thanks in advance for any input on this!

推荐答案

在我看来,telnet方式似乎是最干净的.

The telnet way seems to be the cleanest in my opinion.

但是,如果您想发挥创造力,则可以创建一个简单的关机捆绑软件,并在准备好重新部署之前进行安装.确保已自动部署,以便在安装捆绑软件时将其激活.激活此捆绑包后,其工作是彻底关闭当前正在运行的Equinox容器.

However, if you want to be creative you can create a simple shutdown bundle that you install before you get ready to redeploy. Make sure you have auto-deploy on so the bundle is activated when installed. When this bundle activates it's job is to cleanly shutdown the current running Equinox container.

我仍然建议采用telnet方法,因为在尝试重新部署之前,您需要确保已关闭容器.

I would still suggest the telnet approach as you need to make sure your container is shutdown before you attempt to redeploy.

如果您不喜欢上述任何一种方法,请查看 Apache Karaf .您可以发送正在运行的容器命令.您甚至可以停止,卸载然后重新安装所有捆绑软件,而无需停止Karaf.

If you don't like any of these approaches take a look at Apache Karaf. You can send a running container commands. You can even stop, uninstall then reinstall all your bundles without ever stopping Karaf.

Karaf可以在Apache Felix或Eclipse Equinox之上运行.

Karaf can run on top of Apache Felix or Eclipse Equinox.

这篇关于在詹金斯上持续部署基于OSGi的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆