factor server function from ::run