0

I have implemented a HTTP server using the Poco-libraries. It runs a REST service and everything works fine.

The HTTP server runs as a daemon on a Linux system.

Now I want to implement a functionality into the REST service that restarts the HTTP server daemon itself.

I use popen to call a shell command to restart the daemon. The daemon restarts and I can see via netstat -plten and ps -aux that the server gets a new pid and is listening on port 80. But it does not handle any incoming HTTP requests.

If I type the shell command directly into a terminal, the daemon restarts, gets a new pid and handles incoming HTTP requests.

What could be wrong?

EDIT

I have also tried calling the shell command with system(command); and std::thread(std::system,command).detach(); but the result is the same.

1 Answers1

0

I found a solution.

When creating the Poco::Net::HTTPServer, I create a Poco::Net::ServerSocket to go along with it. I need to close that socket before restarting the daemon.