All right welcome back.
So in this lesson we're going to take yo camp and get it deployed using her rocket and your camp is
is pretty different from the simple application that we deployed in that it has database uses mongered
DBI.
Otherwise it's actually the exact same process.
We still need to create the app using Heroku create.
We need to use get an ad get commit and then push to Heroku.
The only difference is that we have to figure out how to get our database to run as well on her Oku
because Mongo is running locally on this cloud nine instance.
Remember I have my Man-God process running here and I'm connecting to this when I use mongoose.
So we're going to have to get around that and I'll show you how to do that.
Before that we're going to start by just getting the app on there and it won't work right away.
We'll see an error.
It will say something about mongoose or connecting to the database there's an error or a connection
refuse something like that.
But we're going to get it on Heroku first following the exact same steps.
So if you are following along I made a nother version of it deployed which is just where the this version
of the app that I'm deploying will go.
One thing to note is that I will continue to add new features to the camp.
So this is not you know the final version by any means.
I just wanted to get this deploying process out of the way so that everyone could see it.
I got quite a few questions and and curious students asking when are you going to add this section.
So I just said do this first.
Even though the app isn't necessarily or not even really close to being done yet.
So we will be deploying continually as we move forward with new content and new features in the UPCAT
.
OK so first thing let's do get status.
Well actually even before that let's just make sure the app runs node APTA J us
visit the page here looks good.
Things are working.
That's all we need to see for now.
So our goal is to get this on her.
So I'll stop that.
Make sure we are in the correct directory.
Yup can't VLF and deployed you can be in any your camp directory.
You likely only have one camp but make sure that we're in a good repository.
So do get in it.
Make sure we add all this stuff.
So for now we'll just do it get at it commit.
Let's just say initial deploy commit.
Great.
Now we need to go and do Heroku create and you may need to and I may need to do Heroku log in as well
depending on lugged me out or not.
Nope.
So it worked just fine even though I had quit my browser.
So Heroku create made it made us this new space sheltered Stream 5 8 4 5 7.
Of course yours will be different.
That's the point.
These are all unique but hopefully you have something as calming and peaceful as sheltered stream.
So we have that done Heroku create.
Now all we have to do remember is push our code up to Heroku get push Heroku M..
One thing to remember is that we need to make sure our package that Jason has that start script start
at at the beginning we just want it to run node X..
Yes.
So we'll save that.
Let's also make sure all of our dependencies are here.
Body parser Ejay ass express express session method override Mangus passport passport local passport
local mongoose.
If we're missing one it's not the end of the world we can come back and add it and then push again to
Heroku.
But it's much better to just not have to do that.
All right so we do need to add that one change get ad package up Jaison get commit we'll just say ad
start script great.
Now the magic part get push Heroku master.
This is again going to take a little bit.
What happens though takes this code pushes it to Heroku.
But that's not it.
It actually runs the code on her oku.
So it starts by doing NPM install installing all of these packages.
The next thing that it does is run that start script.
So it's going to run node app Dutch apps and then hopefully it's deployed running here.
However I do know that there is a problem which is that we haven't handled the Mongo database but if
we do take a look at the open that we just get that Handey application error that is masking any issues
.
So we obviously can't tell exactly what's wrong.
Remember the way to do that is to run Heroku logs.
It's important to note that we have multiple Heroku apps on this cloud nine instance where we had the
original one and the simple home in about page application if you want to call it an application really
and then golpe camp here.
So depending on what directory I am in if I'm in your camp in this directory when I run Heroku logs
it's going to give me the logs for this app.
Same thing if I'm in the simple deploy demo app and it's going to give me Heroku logs for that.
So I just want to make it clear it's not like you've run Heroku once for your entire computer or for
your entire system.
It depends on the directory you're in.
Just like when you run get status it depends on which repository you're in.
So here's what we see.
Scroll up.
Here we go.
Looks like it ran node at Dodger.
Yes and it got to this Mongo D-B or yeah mongoose Mongo.
Connection refused.
So some of you have actually seen this lot of you posted this in the comments.
This happens when you're not running the mango process or Man-God process in the background.
So basically this is the way that node tells you that it's failed to connect to a database.
So that's obviously a problem that's not connected to the database.
Before I show you how to fix that I do want to show one kind of cool thing which is that we can actually
run commands terminal commands like LS or create files with touch or remove things or run NPM install
remotely on the Heroku space on our workspace on Heroku.
From this command line.
So let's say I just wanted to do ls see what files are on this Hiroki space that we created.
The containers that they call it.
If I do Heroku run and then the command.
So Heroku run LS is going to actually connect to the Heroku server and run the command.
LS get the output and bring it back to me here in C running.
LS attached a terminal every go.
So this is all that we have on her book so I could look at node modules for instance let's say something
wasn't working.
I got an error saying that mongoose wasn't installed.
Well I could verify Roku run LS node modules to see what node modules are installed and it will take
a moment because it is doing this remotely.
There we go and you can see.
All right.
So these are all the node modules installed Mongo there Mongoose is here.
But if it wasn't here then and we would know OK we need to make sure we have it installed on this Heroku
machine.
And what we could do is also something like Heroku run NPM install mongoose dash dash.
Save we don't need to do that but let's say that somehow it didn't get installed.
We didn't have it in the package.
Jason you can run code on that using Heroku run