question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem facing while pushing code

See original GitHub issue

hi i am using following code snippet to push my code to Cf.

try {   
  File artefactFile=new File("D:/PROVIDER COCKPIT/DEPLOYING JARS/SpringBootRestApp-0.0.1-SNAPSHOT.jar");
  File metaDataFile=new File("D:/PROVIDER COCKPIT/DEPLOYING JARS/sample.yml");
  YamlConfigDetails ymlBean = new YamlConfigDetails();
  Map<String, Object> yamlConfigDetails = ymlBean.getYamlConfigDetails(metaDataFile);
  @SuppressWarnings("unchecked")
  LinkedHashMap<String, Object> apps = (LinkedHashMap<String, Object>) yamlConfigDetails.get("applications");
  Integer memory = Integer.parseInt(apps.get("memory").toString());
  Integer instances = Integer.parseInt(apps.get("instances").toString());
  String buildpack = (String) apps.get("buildpack");
  String command = null;
  String domain = (String) apps.get("domain");
  String appName = 12345 + "_" + 12345+ "_" + 0.1;
  try {
    LOGGER.info("creating application starting:---");
    Mono<Void> push = defaultCloudFoundryOperations.applications()
        .push(PushApplicationRequest.builder().
        name(appName).
        path(artefactFile.toPath()).
        memory(memory).
        command(command).
        domain(domain).
        buildpack(buildpack).
        instances(instances).
        randomRoute(true).
        noRoute(false).
        noStart(false).
        build());
    LOGGER.info("creating application completed:---");
    push.doOnSuccess(x -> System.out.println("deployed succesfully !!")).subscribe();
    push.doOnError(x -> System.out.println("deployment failed !!")).subscribe();
    LOGGER.info("pushing application completed:---");
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
  }
} catch (Exception e1) {
  LOGGER.error(e1.getMessage());
}

i am using this service in my controller. when i invoke that endpoint. it is JUST creating application in CF. deploy issue

but there is no route binded to application & application is always in stop condititon.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nebhalecommented, Nov 7, 2017

Looking over your code there are a couple of areas for improvement that will push your application properly.

  1. There is no need for you to parse your manifest directly. The project provides both the tools and the APIs for using a reference to a manifest directly.

  2. .subscribe()-ing twice to a reactive flow causes the flow to be triggered twice. Therefore, in your code, you’re telling the application to push twice in close succession leading to one (but which one is undefined) to fail.

  3. The entire API is asynchronous and non-blocking. Therefore, once you’ve subscribed to your flow, control is returned to the calling method which promptly completes, before even the first response (push is an orchestration of ~13 network requests) has returned. Therefore, your application has completed before the flow has completed. Some environments like Servlet containers have a long enough lifecycle that even if your calling method returns, the execution can still complete before the container closes. If you are running your application in an environment where the method lifecycle is dictates the application lifecycle, you’ll need to ensure that your method is kept alive until the flow is complete.

An example of improving all of these issues would be as follows:

CountDownLatch latch = new CountDownLatch(1);

this.cloudFoundryOperations.applications()
    .pushManifest(PushApplicationManifestRequest.builder()
        .manifests(ApplicationManifestUtils.read(Paths.get("D:/PROVIDER COCKPIT/DEPLOYING JARS/sample.yml")))
        .build())
    .doOnSubscribe(s -> this.logger.info("Deployment Started"))
    .doOnError(t -> this.logger.error("Deployment Failed", t))
    .doOnSuccess(v -> this.logger.info("Deployment Successful"))
    .subscribe(System.out::println, t -> latch.countDown(), latch::countDown);

latch.await();
0reactions
parasuram-tanguturucommented, Dec 6, 2017

@nebhale how to replace System.out::println with logger. in .subscribe(System.out::println, t -> latch.countDown(), latch::countDown);

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix 'failed to push some refs to' Git Errors - Komodor
It occurs when a developer attempts to push committed code to an external git repository. The ability to push code stopped working suddenly,...
Read more >
How to solve git push error while pushing to temp_branch on ...
I am working on the team project on GitHub. I am facing the error : Updates were rejected because a pushed branch tip...
Read more >
Error: failed to push some refs to – How to Fix in Git
This error mainly occurs when you attempt to push your local changes to GitHub while the local repository (repo) has not yet been...
Read more >
GIT : Resolving " Code push Rejected " - YouTube
GIT is most used code repository. Problem Statement :Sometimes, we forget to pull before Push. In such scenario, if commit has been done...
Read more >
Git Error | GitHub Error: failed to push some refs to '[REPO URL]'
... Git/GitHub and just came across the message "failed to push some refs to ..."?Don't worry, this video shows the cause of this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found