Dev: apache: refactor pid use

ApachePID was a global variable set in a function as a
side-effect. This patch makes the pid processing more obvious.