1

I'm running a my service on a Amazon EC2 create from a CloudFormation script.
I put service file in /etc/rc.d/init.d/myService. (includeing "start" and "stop" functions).
I've also linked it like this:
/etc/rc.d/rc0.d/K00myService -> /etc/rc.d/init.d/myService
/etc/rc.d/rc6.d/K00myService -> /etc/rc.d/init.d/myService

But, when I delete the CloudFormation stack and the EC2 goes down the "stop" service is never called.

The linux version:

~> cat /etc/*-release
NAME="Amazon Linux AMI"
VERSION="2015.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2015.03"
PRETTY_NAME="Amazon Linux AMI 2015.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2015.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2015.03

What am I missing?

1

Does your init script create a lock file /var/lock/subsys/<service> when starting? If it doesn't, the shutdown process will assume the subsystem isn't running, and won't attempt to stop the service.

If this is the issue, you need to modify your start and stop scripts so that the start script creates the lock file on startup (e.g. by running touch /var/lock/subsys/<service>), and the stop script removes the lock file on shutdown.

Sources:

| improve this answer | |

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.