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
  • 33,478
  • 73
  • 290
  • 513

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
  • 554
  • 6
  • 15