1

I have a spring-boot application up and running, with actuator endpoints configured mainly the /shutdown endpoint. I've been shutting it down (previously) with ^C and now am shutting down with curl -XPOST https://address:port/shutdown. My question is how would I map a command like that to a javascript function so I can shutdown the application with the click of a button?

j-money
  • 499
  • 1
  • 9
  • 27

2 Answers2

3

There is no way to execute curl command using javascript function so better use AJAX.

See below threads.

Executing curl from Javascript?

https://stackoverflow.com/a/31179836/6572971

Otherwise you can use java code to make it shutdown like below.

Programmatically shut down Spring Boot application

Alien
  • 13,439
  • 5
  • 35
  • 53
0

By using Fetch ?

const myPost = async (postBody) => {
  const rawResponse = await fetch('https://address:port/shutdown', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(postBody)
  });
  const response = await rawResponse.json();
  console.log(response);
);
Ashley Davis
  • 9,559
  • 7
  • 63
  • 83
servatj
  • 166
  • 2
  • 9