1

I am attempting to create a new EC2 instance and I am supplying user-data to the instance at create time. My user-data executes some bash commands that modify the parameters of a properties file for another application (myApplication). The intent is to modify the configuration of myApplication BEFORE it starts. myApplication is configured to start from /etc/init.d .

I'm basically trying to do what is described here

I see that the chkconfig configuration for /etc/init.d/cloud-init-local is set with priority 50. I am assuming that this is the mechanism by which my user-data script is executed.

myApplication is also configured with chkconfig, but with priority 90. The plan is that the user-data is executed BEFORE myApplication starts.

But, this is not what I am experiencing. I can see in the cloud-init-output.log file that my user-data does get executed, but myApplication has already started.

Is my assumption that my user-data script is executed by /etc/init.d/cloud-init-local wrong? Is my expectation of the behavior of the boot sequence incorrect?

Any help is appreciated, thanks!

0

I think you hit a systemd bug. (One that they thought was a good idea.) Specifically to improve boot speed on sysv scripts that are imported they are run in parallel UNLESS you configure LSB dependencies, which sysv init ignores.

The way around this is to either

  1. convert both init scripts to be systemd scripts with systemd dependencies.
  2. add dependencies to both init scripts.
  3. choose another init system that does not try to be smarter than you.
  • Thank you for the reply. I'm not familiar with the different init systems - are you saying that if I configure LSB that in my case it will be ignored? I have been reading about LSB and it states - Required-Start: boot_facility_1 [boot_facility_2...] facilities which must be available during startup of this service. The init-script system should insure init scripts which provide the Required-Start facilities are started before starting this script. Does this insure that the required script is COMPLETED? – ben_979 Jun 22 '17 at 18:00
  • Yes, and you also need the correct provides line as well, but since you are adding both required start in one and provides in the other you can just pick something unused. On the other hand my answer would be completely wrong if you aren't using systemd. – hildred Jun 22 '17 at 18:29
  • Thank you. setting the Required-Start seems to have worked. – ben_979 Jun 29 '17 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.