Write pidfile and pidfile2 only after successful start

PID is written to a file too early. The value will be overwritten in case when app loading fails. The usual case is if the port is occupied by the running process, and if uwsgi is started for the second time the pidfile is overwritten even if the application fails to start, resulting a loss of original pid number.

This change will prevent the loss of a valid PID number.

Thanks,
Janos