extract start_server function for reuse