5

On RHEL6/CentOS6 what is the upstart way to:

chkconfig add my-svc
chkconfig my-svc on

Explanation: I have written an /etc/init/xvc0.conf job. I can do

start xvc0

on the CLI, but after reboot initctl list gives me

...
xvc0 stop/waiting
... 

So I need a way to insert my job in the boot upstart sequence.

(Incidentally, while researching this I found (Ububtu) posts advising to create the job as /etc/event.d/xvc0. That appears to be ineffectual - start xvc0 gives Unknown. What gives? And what is then the purpose of /etc/event.d?)

Cheers, alf

EDIT

While not a direct answer to my question I have found what follows:

  1. If, in xvc0.conf I use the directive:

    start on runlevel [2345] stop on runlevel [016]

rather then the longhand:

start on runlevel 2
start on runlevel 3
...
stop on runlevel 0
...

The job is started at boot

  1. I have found pointers to the (extremely confusing) directives:

    start on stopped rc RUNLEVEL=[2345] stop on starting rc RUNLEVEL=[016]

Which are also used in the prefdm.conf job and which also appear to work, but in a way that subtly differs from the former (did not understand how) and basically mess up what I am trying to do (which is, starting agetty on /dev/xvc0).

Even so, the question above stands - editing scripts (and in a language of a rather opaque syntax) in order to achieve automatic startup seems raher inconvenient to me.

Alien Life Form
  • 2,279
  • 2
  • 21
  • 31
  • you answered your own question with the last edit – Mike May 08 '13 at 14:16
  • Not sure about that - for the reasons explained in the last paragraph: is editing the script the way to change activation mode and levels? If so I'd say it is vastly inferior to chkconfig - no easy way to find out what will start and when. – Alien Life Form May 08 '13 at 14:43
  • 2
    I wouldn't even try to use upstart jobs in EL6. It was just an accident of timing that upstart was included in EL6 in the first place, and it was never really developed; only its init backward compatibility is really used. It has since been abandoned, and EL7 most likely won't ship it, in favor of systemd, so if you write an upstart job instead of an old-style init script, it will not run in the future. – Michael Hampton May 08 '13 at 15:43
  • @MichaelHampton: this is quite interesting - not to mention frustrating (of course most sysadmins have nothing better to do than tracking the changing mindsets of RH's architects.) – Alien Life Form May 09 '13 at 09:49
  • Oh, I don't track Red Hat _that_ closely, but I do run Fedora myself, and so I see what's coming well in advance. Upstart was an experiment that ran for maybe two releases before being discarded. It just so happened that those two releases were where Red Hat picked up code to build EL6. I think Ubuntu is the last distribution still using upstart, and they'll also have to abandon it eventually, or risk losing their market position. Virtually every other distribution has switched to systemd at this point, or plans to. – Michael Hampton May 09 '13 at 16:36

3 Answers3

3

In the job itself using:

start on runlevel [2345] 
stop on runlevel [016]

rather then the longhand:

start on runlevel 2
start on runlevel 3
...
stop on runlevel 0
...

has the effect of starting the job at boot. Possible reason: every 'start' overrides the previous one (rather then adding to it).

As far as changing or documenting the starting/stopping of a job from the CLI, à la chkconfig, that appears not to be possible (a big upstart flaw, if you ask me). The other finer points go unaddressed, but see @MichaelHampton's comment to my question as to why the exercise is rather pointless anyway (in the RH universe, at least).

Alien Life Form
  • 2,279
  • 2
  • 21
  • 31
-1

I would set the runlevels i wanted the service to start up in as well

chkconfig --level 345 my-svc on
konstructor
  • 101
  • 1
  • chkconfig does not know about my newfangled job - it is my understanding that chkconfig does not interoperate with the new upstart machinery and just takes care of the legacy Sysv-style stuff. I may be wrong, though. – Alien Life Form May 08 '13 at 11:09
  • then you can write a sysv script that can be added to runlevels of the machine. http://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html – konstructor May 08 '13 at 12:14
  • Yes at least for some tasks I could, but the entire sysV shebang is going away soon so, why bother? However this particular task serves to reinstate an inittab feature, so while I guess I could create a script that goes "start xvc0", it would be even more fanciful. – Alien Life Form May 08 '13 at 15:38
-1

I don't think there is any way to control upstart from the command-line. I did not see anything beyond initctl on CentOS 6.x, while googling for this. You're only option appears to be to edit the upstart config files.

slm
  • 7,355
  • 16
  • 54
  • 72