从cloudfoundry任务命令访问Java可执行文件(cf运行任务) [英] Accessing the java executable from a cloudfoundry task command (cf run-task)

查看:132
本文介绍了从cloudfoundry任务命令访问Java可执行文件(cf运行任务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要Java可执行文件才能通过 cloudfoundry任务命令运行java -jar。

I need the java executable to run a java -jar from a cloudfoundry task command.

这是我尝试运行任务:

cf run-task bignibou-batch "java -jar bignibou-batch/build/libs/bignibou-batch.jar"

这是我收到的错误消息:

Here is the error message I get:

2016-12-24T12:53:30.002+01:00 [APP/TASK/358e02df/0] [ERR] bash: java: command not found

我的清单按如下方式使用Java buildpack(请参阅 bignibou-batch 应用在底部):

My manifest uses the java buildpack as follows (see bignibou-batch app at the bottom):

---
buildpack: https://github.com/cloudfoundry/java-buildpack.git
memory: 1024M
env:
  APPLICATION_URL: http://bignibou-server.cfapps.io/
  APPLICATION_MAIL_NO_REPLY_ADDRESS: balteo@bignibou-server.cfapps.io
  SPRING_PROFILES_ACTIVE: cloud

applications:
  - name: bignibou-server
    path: bignibou-server/build/libs/bignibou-server.jar
    env:
      APPLICATION_GOOGLE_API_KEY: *******************
  - name: bignibou-batch
    path: bignibou-batch/build/libs/bignibou-batch.jar
    no-hostname: true
    no-route: true
    env:
      JAVA_OPTS: -Dspring.batch.job.names=messagesDigestMailingJob

编辑:当我尝试如下设置Java buildpack的位置时:

edit: When I try to set the location of the java buildpack as follows:

cf run-task bignibou-batch "$PWD/.java-buildpack/open_jdk_jre/bin/java -jar bignibou-batch/build/libs/bignibou-batch.jar"

$ PWD 变量在发送命令之前已在我的本地计算机上解析...

The $PWD variable is resolved on my local machine before the command is sent...

推荐答案

通常,我们认为安装的JRE的位置以及运行应用程序所需的命令,其内部详细信息可能会发生更改,而没有兼容性限制。据我所知(运行Java Buildpack团队将近四年),没有任何契约义务要求将液滴安装在 / home / vcap 上,这就是为什么我们非常谨慎地在命令中使用 $ PWD

In general, we consider the location of the installed JRE, as well as the command required to run the application, an internal detail subject to change without compatibility restrictions. To the best of my knowledge (running the Java Buildpack team for nearly four years) there are no contractual obligations requiring droplets to be mounted at /home/vcap either, which is why we're very careful to use $PWD in our commands.

其他基于Java任务的早期用户有允许分段完全发生(这将确保在命令中正确放置内存计算和 JAVA_OPTS 之类的东西),然后使用该命令行而不进行修改。

Other early users of Java-based tasks have allowed staging to happen completely (which would ensure that things like memory calculation and JAVA_OPTS are properly placed in the command) and then use that command line without modification.

及早解决 $ PWD 所遇到的问题比其他任何事情都可以避免。您可能应该做的第一个更改是将双引号( )切换为单引号('),确保 $ 不会立即得到解决。有可能在管道中的其他地方,环境又得到了较早的解决,可能需要 \ $ 逃脱,但我会坚持下去,直到您确定看到它为止。

The issue you're seeing with $PWD being resolved early is one of escaping more than anything else. The first change you should probably make is to switch from double quotes (") to single quotes (') which should ensure that $ isn't resolved immediately. It's possible that somewhere else in the pipeline the environment is resolved again early possibly necessitating a \$ escape, but I'd hold off on that until you're sure that you're seeng it.

这篇关于从cloudfoundry任务命令访问Java可执行文件(cf运行任务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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