This also extracts the gid/uid detection and upstart actions into reusable module to provide consistent behavior.