Injecting a sequential job

Clint Byrum clint at ubuntu.com
Wed Feb 29 23:28:21 UTC 2012


Excerpts from Svein Seldal's message of Wed Feb 29 14:12:35 -0800 2012:
> Hi Steve
> 
> Thanks for answering.
> 
> > Could you provide some more detail about what the job is that you're trying
> > to run?  There's probably a solution that lets you achieve your end goal,
> > but would need to know what that end goal is to provide useful guidance
> > here.
> 
> Yes sure. A bit complex I'd amit. I hope you can bear with me:
> 
> Its an embedded product which has two distinct modes to run in: 
> production mode and normal application mode. Application mode is 
> standard rc runlevel as on a normal desktop installation. The production 
> mode is a special mode used in production where no normal services 
> should start except a few handpicked ones (static eth0, ssh).
> 
> The decision between prod.mode is done from a script. I've been 
> experimenting with starting this as a job task. One of the purposes in 
> production mode is to have a very specific network setting and publish 
> this on avahi.
> 
> In app mode network manager provides the user's network configuration. 
> One of the challenges I'm facing is how to handle network manager in 
> production mode. NM holds the user's config and not the network setup 
> needed in production mode. NM starts very early (even before any 
> net-device-up is emitted), thus I'm experiencing a race between my 
> script and NM.
> 
> I've been experimenting with "start on starting dbus" (which is a common 
> denominator between nm and avahi) to be able to stop nm and set the 
> network manually when going to prod.mode. Yet this has a hacky feel to 
> it. This script is vital for the product, so it needs to be simple. 
> Complex rules will fail.

I don't think that is hacky at all.

It sounds like network-manager is not desired for production mode, and
you want to replace its functionality with something else. A job which
cancels the start of network-manager is actually *exactly* what I would
recommend in that case.

Since you also want to interact with avahi, it seems like what you need
is a two part configuration:


# prod-mode
start on starting network-manager
pre-start script
  if prod_mode_active ; then
    stop network-manager
  else
    stop # Stops prod-mode
  fi
end script

# prod-mode-avahi
start on started prod-mode and started avahi-daemon

script
  statically_configure_network
  send_network_config
end script

Since we stop prod-mode if the machine is in 'app mode', prod-mode-avahi
only gets started after we've made sure network-manager isn't going
to start.



More information about the upstart-devel mailing list