move up call pcntl_signal_dispatch above error logging to prevent raising an error on term signal

I moved up signap dispatch above error logging, because when a SIGTERM signal sent by a kill command, the script reached that statement, and generated a 'Socket disconnected' error, though there was no actual error, the disconnection of socket was expected.
It can prevent sending unnecessary error mails or logging errors.