fixing server restart logic to wait for server initialization