Turning our simple code into a service using upstart

Since we started the node application manually in the Terminal, closing the SSH connection or hitting Ctrl + C on the keyboard will stop the node process, and therefore our Hello World application will not work anymore. Amazon Linux, unlike a standard Red Hat-based distribution, comes with a system called upstart.

This is fairly easy to use and provides a couple of extra features that traditional System-V bootup scripts don't have, such as the ability to respawn a process that died unexpectedly. To add an upstart configuration, you need to create a file inside /etc/init on the EC2 instance.

Here is the code to insert it in /etc/init/helloworld.conf:

description "Hello world Daemon"# Start ...

Get Effective DevOps with AWS - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.