Detect service base directory automatically