Scheduler for PCF #service


shruthi s
 

Hi,
I have a spring boot application implementing a commandline runner and terminates after the process. The main class looks like:
@SpringBootApplication
public class MyClass implements CommandLineRunner{
    @Override
    public void run(String... strings) throws Exception {
if(strings[i].equals("A"){
  do processA();
}
else if(strings[i].equals("B"){
  do processB();
}
System.exit(0);
}
 
public static void main(String[] args) throws Exception{
            SpringApplication.run(CTFRetryNotification.class, args);
    }
}

I run this command: java -jar executable.jar arg0 arg1 -Dspring.profiles.active=dev. It workd fine when i run the command in terminal. 

I am now trying to push this executable jar to PCF as an application, bind it to the scheduler and then schedule a job with command which executes the jar.
I am using the below manifest file to push the app:
---
applications:
- name: my-app
  memory: 1024M
  host: my-app
  domain: my.pcf.domain
  health-check-type: process
  instances: 1
  timeout: 60
  path: executable.jar
  env:
    SPRING_PROFILES_ACTIVE: dev 
    JBP_CONFIG_JAVA_MAIN: '{java_main_class: com.abc.MyClass}'
    JBP_CONFIG_JAVA_MAIN: '{ arguments: "arg0 arg1" }'

Command to push:  cf push -f manifest.yml --no-route

The app starts but suddenly crashes with the following message: 
 [API/0] [OUT] Process has crashed with type: "web"
 [API/0] [OUT] App instance exited with guid 7bd4c9a8-a67e-471d-ad39-43623b6f29cd payload: {"instance"=>"d296990c-ead6-48e0-5308-3657", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"Codependent step exited", "crash_count"=>2, "crash_timestamp"=>1518194091169216190, "version"=>"ed0bbd60-9e1c-4d95-97aa-b750446332d5"}

i am trying to figure out the command i can use to run the jar by using run-task command in cf cli but i cannot get it to work.
cf run-task my-app '$PWD/.java-buildpack/open_jdk_jre/bin/java -Dspring.profiles.active=dev -cp $PWD/. org.springframework.boot.loader.JarLauncher arg0 arg1'

This command fails " Incorrect Usage: unknown flag `c'"
I tried using double quotes around the command but it fails "out of memory".

Has anybody done something like this in PCF? What would be the command i can use to run the jar? Thanks in advance




Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.