In case you missed it, we recently announced a new version of the StrongLoop Process Manager.
What is StrongLoop Process Manager? It’s an enterprise-grade production runtime process manager for Node.js. StrongLoop Process Manager is built to handle both the vertical and horizontal scaling of your Node applications with ease.
One of the coolest features of the new release is support for Docker.
In this blog post I am going to show you how to install and use the offical StrongLoop Process Manager Docker image. Let’s get started shall we?
curl -s https://strong-pm.io/docker.sh | sudo sh
The created service will use port 8701 for the Process Manager API and port 3000 for your app. If the server reboots, the Process Manager will automatically restart.
Well, that would not satisfy those of you that need to know how things work, would it? So in the rest of the blog I’ll explain how that bit of a script does its work, by showing you how to do it the hard way!
Setting up a server can be daunting, and installing Node on a server isn’t always a walk in the park either. Fortunately, we’re talking about Docker here so we get to wave a wand and make all our problems go away! Well, not all our problems, but at least a few. Here’s what our server needs:
- A host (physical or virtual) capable of running Docker. I recommend something RHEL/Fedora-based because of the extra protection offered in the event that your Docker container is breached.
- That’s it! You don’t even need to install Node on your server!
Here’s what your workstation needs:
- Node (so you can
npm install -g strongloop)
Since this article is about deployment rather than development I won’t be covering how to install Node in your dev environment.
Here’s the general recipe:
- Install Docker
- Install the strong-pm docker image
- Deploy your app!
Many (many, many) articles have been written about how to install Docker. Personally, I found the official documentation to be the best. If you are in a rush and are running Ubuntu, Debian, Linux Mint, Fedora, AWS Linux, CentOS, or RHEL and the version you are running was released in the last year or so, there’s a handy one-line installer you can use:
curl -sSL https://get.docker.com/ | sudo sh
If you aren’t lucky enough to have that work for you, you’ll probably have to go read the docs.
Protip! I highly recommend following the instructions for sudo-less Docker.
Install The strongloop/strong-pm Docker image
In short, what we need to do now is pull down the
strong-pm Docker image, start it up, and then set up an
init script to make sure it starts the next time your server reboots.
Conveniently, if Docker is told to run an image that hasn’t been pulled yet, it will pull it automatically. This means you can cover the first two steps with the following command:
docker run --detach --restart=no \
--publish 8701:8701 --publish 3000:3000 \
--name strong-pm-container \
Great! Now you’ve downloaded the
strongloop/strong-pm Docker image, started a new container in the background (
--detach) named it
my-app-pm. Additionally, we’ve told it to publish container ports 8701 and 3000 and as host ports 8701 and 3000, respectively.
If you don’t care about your application coming back up after a server reboot and you just want to take it for a spin, you’re done with this part and you can go straight to the “Deploying Your App” section.
If you want to set up something a little closer to production, we’ve got one more step to do.
This is where
systemd come in. If you were lucky enough to have the one-liner from the “Installing Docker” section work for you, then there’s a good chance you’re running a system that comes with
If you’ve already drank the ‘systemd’ Kool-Aid, then you can follow those instructions.
If you are in a rush you can probably get away with simply copying the following example into
description "StrongLoop Process Manager Container"
author "StrongLoop <email@example.com>"
start on filesystem and started docker
stop on runlevel [!2345] respawn
exec /usr/bin/docker start -a strong-pm-container
You’ll want to create a target like this one:
Description=StrongLoop Process Manager Container
ExecStart=$DOCKER start -a strong-pm-container
ExecStop=$DOCKER stop -t 2 strong-pm-container [Install] WantedBy=default.target
Just like with the
Upstart job, this one is so simple you can probably just copy/paste the above
systemd example right into
Deploy Your App
Alright, now that we’ve installed Docker and a containerized instance of the StrongLoop Process Manager, we’re ready to deploy our app. This one is easy:
slc deploy http://docker-host:8701/
Now that you know how to do it the hard way, you can always use the script we provided you right at the top. Happy Deploying!
Watch the demo! Check out this short video that gives you an overview of the StrongLoop Process Manager.
Sign up for the webinar! “Best Practices for Deploying Node.js Applications in Production” on April 16 with StrongLoop and Node core developer Sam Roberts.
In the coming weeks, look for more enhancements to the StrongLoop Process Manager and its runtime capabilities. But for now, here’s a few additional technical articles that dive into greater detail on how to make the most of this release:
- Best Practices for Deploying Node in Production
- How to Test Node.js Deployments Locally Using StrongLoop Process Manager
- How to Run StrongLoop Process Manager in Production
- How to Secure StrongLoop Process Manager with SSH
- Best Practices for Deploying Express Apps with StrongLoop Process Manager
- How to Create and Run StrongLoop Process Manager Docker Images