0

To reload NGINX in terminal

Enter sudo then

nginx -t 
nginx -s reload

Are the commands to test and reload NGINX, however, how can this be done from a Java web application, which I need my web application to be able to control NGINX at least to test and reload.

quarks
  • 31,298
  • 67
  • 266
  • 478

1 Answers1

0

You need to run the command using ProcessBuilder like below.

ProcessBuilder processBuilder = new ProcessBuilder();
// Run a shell command
processBuilder.command("bash", "-c", "nginx -t");
Process process = processBuilder.start();
Vishal Patel
  • 534
  • 5
  • 15