server script, make error exit function