• Servers and Tools


From the class:  Processes

Before we wrap up the class, I wanted to give you a couple examples of popular programs that you may have used and how they use processes, or what their processes look like. And to start off, we're going to take a look at Meteor. And if you haven't installed Meteor before, you can just go ahead and paste in this cURL script. And what it'll do is install Meteor. And it takes a couple of minutes to finish.

And once it does, we'll go ahead and create a Meteor application. We can create the Meteor application using the Meteor command line tool and type Meteor create. And I'll just name this application app. Then I'll change into the app directory and start up the Meteor development server. So this is going to be what you would be running when you're developing locally on your laptop, not what you would be running in production.

Once this starts up, I'm going to type ps af again and we'll take a look at the different processes. If you're following along and you get any errors in trying to start up Meteor, just to try to start it again, and on the second try-- sometimes it just takes two tries for some reason.

But now that the application is up and running in the foreground up top, I've typed ps af down bottom. And notice that there's a master process here, which is the master Meteor process, and it's running two children processes. And its such a long file path to get there that we can't quite see what it is, so I'll just tell you.

This top process here is the Node.js process. So that's Node.js. And the one down below is because Meteor's running its own version of Mongo-- that's the database. And so it has bootstrapped a version of Mongo for you, and is running it as a process that it's controlling with this top level process here. So when you run Meteor in development, you're actually running three processes-- the master process and then two children processes.

Let's install MongoDB directly and tried it out. We can use Ubuntu's apt get Package Manager to install MongoDB directly. And we'll run it as its own process. And when that completes, we should be able to type ps. And this time I'm going to look at all the processes. And notice that without us even having to do anything, just by installing it, it started up automatically.

So here's that command, user bin MongoD. And it's loading up the configuration that's in the et cetera folder. And it's running under pid one, and so you can see that it's already been detached and is running on its own. So now MongoDB is running as its own process on our machine, and you can log into it using the Mongo command line tool just like you're used to. So we can type mongo I believe it is, and that connects to our MongoDB process that's running in the background.

So I hope this gives you an intuitive sense of what processes are and some of the primitive ways that we can work with them. And that's really what we're doing in deployment environments. We're installing software and running processes. And the processes can run on the same computer like we see here in this list, or they can run on separate machines.

For example, if you want to scale out a system, one of the things that you can do is to create additional processes that use more than one CPU, as an example. So in the next couple of classes, we'll get into some of the details of how to manage processes in a more sophisticated way. But also how to use different programs at different levels of the stack in a deployment environment.