Extract common server setup code