1
00:00:00,270 --> 00:00:01,380
All right welcome back.

2
00:00:01,380 --> 00:00:08,790
So in this lesson we're going to take yo camp and get it deployed using her rocket and your camp is

3
00:00:08,950 --> 00:00:15,700
is pretty different from the simple application that we deployed in that it has database uses mongered

4
00:00:15,700 --> 00:00:16,400
DBI.

5
00:00:16,680 --> 00:00:19,570
Otherwise it's actually the exact same process.

6
00:00:19,620 --> 00:00:23,620
We still need to create the app using Heroku create.

7
00:00:23,760 --> 00:00:28,470
We need to use get an ad get commit and then push to Heroku.

8
00:00:28,770 --> 00:00:33,060
The only difference is that we have to figure out how to get our database to run as well on her Oku

9
00:00:33,390 --> 00:00:37,800
because Mongo is running locally on this cloud nine instance.

10
00:00:37,800 --> 00:00:44,580
Remember I have my Man-God process running here and I'm connecting to this when I use mongoose.

11
00:00:45,180 --> 00:00:47,670
So we're going to have to get around that and I'll show you how to do that.

12
00:00:47,850 --> 00:00:52,580
Before that we're going to start by just getting the app on there and it won't work right away.

13
00:00:52,620 --> 00:00:53,550
We'll see an error.

14
00:00:53,720 --> 00:00:58,600
It will say something about mongoose or connecting to the database there's an error or a connection

15
00:00:58,610 --> 00:01:00,170
refuse something like that.

16
00:01:00,390 --> 00:01:04,100
But we're going to get it on Heroku first following the exact same steps.

17
00:01:04,110 --> 00:01:12,630
So if you are following along I made a nother version of it deployed which is just where the this version

18
00:01:12,630 --> 00:01:15,320
of the app that I'm deploying will go.

19
00:01:15,600 --> 00:01:20,600
One thing to note is that I will continue to add new features to the camp.

20
00:01:20,670 --> 00:01:23,700
So this is not you know the final version by any means.

21
00:01:23,700 --> 00:01:28,640
I just wanted to get this deploying process out of the way so that everyone could see it.

22
00:01:28,680 --> 00:01:34,020
I got quite a few questions and and curious students asking when are you going to add this section.

23
00:01:34,020 --> 00:01:35,910
So I just said do this first.

24
00:01:35,940 --> 00:01:40,160
Even though the app isn't necessarily or not even really close to being done yet.

25
00:01:40,530 --> 00:01:46,470
So we will be deploying continually as we move forward with new content and new features in the UPCAT

26
00:01:46,490 --> 00:01:46,980
.

27
00:01:47,510 --> 00:01:51,620
OK so first thing let's do get status.

28
00:01:52,620 --> 00:01:58,740
Well actually even before that let's just make sure the app runs node APTA J us

29
00:02:01,860 --> 00:02:04,290
visit the page here looks good.

30
00:02:04,290 --> 00:02:05,290
Things are working.

31
00:02:05,310 --> 00:02:06,800
That's all we need to see for now.

32
00:02:07,080 --> 00:02:09,840
So our goal is to get this on her.

33
00:02:11,300 --> 00:02:13,830
So I'll stop that.

34
00:02:13,830 --> 00:02:16,780
Make sure we are in the correct directory.

35
00:02:17,160 --> 00:02:21,140
Yup can't VLF and deployed you can be in any your camp directory.

36
00:02:21,150 --> 00:02:27,080
You likely only have one camp but make sure that we're in a good repository.

37
00:02:27,120 --> 00:02:29,600
So do get in it.

38
00:02:30,210 --> 00:02:34,040
Make sure we add all this stuff.

39
00:02:34,230 --> 00:02:39,970
So for now we'll just do it get at it commit.

40
00:02:40,370 --> 00:02:45,600
Let's just say initial deploy commit.

41
00:02:45,600 --> 00:02:47,160
Great.

42
00:02:47,190 --> 00:02:54,780
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

43
00:02:54,780 --> 00:02:57,110
depending on lugged me out or not.

44
00:02:57,330 --> 00:02:57,770
Nope.

45
00:02:57,900 --> 00:03:01,580
So it worked just fine even though I had quit my browser.

46
00:03:02,100 --> 00:03:09,440
So Heroku create made it made us this new space sheltered Stream 5 8 4 5 7.

47
00:03:09,530 --> 00:03:11,260
Of course yours will be different.

48
00:03:11,730 --> 00:03:12,500
That's the point.

49
00:03:12,510 --> 00:03:18,340
These are all unique but hopefully you have something as calming and peaceful as sheltered stream.

50
00:03:18,660 --> 00:03:21,570
So we have that done Heroku create.

51
00:03:21,570 --> 00:03:29,470
Now all we have to do remember is push our code up to Heroku get push Heroku M..

52
00:03:29,670 --> 00:03:38,280
One thing to remember is that we need to make sure our package that Jason has that start script start

53
00:03:38,950 --> 00:03:41,920
at at the beginning we just want it to run node X..

54
00:03:42,020 --> 00:03:42,690
Yes.

55
00:03:42,910 --> 00:03:44,530
So we'll save that.

56
00:03:44,590 --> 00:03:48,950
Let's also make sure all of our dependencies are here.

57
00:03:49,080 --> 00:03:55,230
Body parser Ejay ass express express session method override Mangus passport passport local passport

58
00:03:55,230 --> 00:03:56,820
local mongoose.

59
00:03:56,820 --> 00:04:01,980
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

60
00:04:01,980 --> 00:04:02,620
Heroku.

61
00:04:02,760 --> 00:04:05,950
But it's much better to just not have to do that.

62
00:04:06,210 --> 00:04:14,850
All right so we do need to add that one change get ad package up Jaison get commit we'll just say ad

63
00:04:15,120 --> 00:04:18,820
start script great.

64
00:04:19,380 --> 00:04:24,670
Now the magic part get push Heroku master.

65
00:04:25,350 --> 00:04:27,400
This is again going to take a little bit.

66
00:04:27,690 --> 00:04:30,720
What happens though takes this code pushes it to Heroku.

67
00:04:30,780 --> 00:04:31,840
But that's not it.

68
00:04:31,860 --> 00:04:34,300
It actually runs the code on her oku.

69
00:04:34,440 --> 00:04:39,180
So it starts by doing NPM install installing all of these packages.

70
00:04:39,240 --> 00:04:43,200
The next thing that it does is run that start script.

71
00:04:43,230 --> 00:04:49,590
So it's going to run node app Dutch apps and then hopefully it's deployed running here.

72
00:04:49,590 --> 00:04:54,990
However I do know that there is a problem which is that we haven't handled the Mongo database but if

73
00:04:54,990 --> 00:05:02,910
we do take a look at the open that we just get that Handey application error that is masking any issues

74
00:05:03,330 --> 00:05:04,140
.

75
00:05:04,590 --> 00:05:07,590
So we obviously can't tell exactly what's wrong.

76
00:05:08,070 --> 00:05:14,480
Remember the way to do that is to run Heroku logs.

77
00:05:14,760 --> 00:05:21,390
It's important to note that we have multiple Heroku apps on this cloud nine instance where we had the

78
00:05:21,390 --> 00:05:28,170
original one and the simple home in about page application if you want to call it an application really

79
00:05:28,530 --> 00:05:30,480
and then golpe camp here.

80
00:05:30,480 --> 00:05:36,270
So depending on what directory I am in if I'm in your camp in this directory when I run Heroku logs

81
00:05:36,270 --> 00:05:38,820
it's going to give me the logs for this app.

82
00:05:38,850 --> 00:05:44,830
Same thing if I'm in the simple deploy demo app and it's going to give me Heroku logs for that.

83
00:05:45,030 --> 00:05:50,940
So I just want to make it clear it's not like you've run Heroku once for your entire computer or for

84
00:05:50,940 --> 00:05:52,300
your entire system.

85
00:05:52,350 --> 00:05:54,510
It depends on the directory you're in.

86
00:05:54,510 --> 00:05:58,650
Just like when you run get status it depends on which repository you're in.

87
00:05:59,190 --> 00:06:00,350
So here's what we see.

88
00:06:00,390 --> 00:06:04,060
Scroll up.

89
00:06:04,500 --> 00:06:05,400
Here we go.

90
00:06:05,400 --> 00:06:09,710
Looks like it ran node at Dodger.

91
00:06:09,710 --> 00:06:16,970
Yes and it got to this Mongo D-B or yeah mongoose Mongo.

92
00:06:17,190 --> 00:06:19,140
Connection refused.

93
00:06:19,470 --> 00:06:23,730
So some of you have actually seen this lot of you posted this in the comments.

94
00:06:23,750 --> 00:06:29,630
This happens when you're not running the mango process or Man-God process in the background.

95
00:06:29,640 --> 00:06:36,450
So basically this is the way that node tells you that it's failed to connect to a database.

96
00:06:36,570 --> 00:06:40,740
So that's obviously a problem that's not connected to the database.

97
00:06:40,740 --> 00:06:47,310
Before I show you how to fix that I do want to show one kind of cool thing which is that we can actually

98
00:06:47,310 --> 00:06:54,660
run commands terminal commands like LS or create files with touch or remove things or run NPM install

99
00:06:55,200 --> 00:07:00,660
remotely on the Heroku space on our workspace on Heroku.

100
00:07:00,840 --> 00:07:02,480
From this command line.

101
00:07:02,970 --> 00:07:10,520
So let's say I just wanted to do ls see what files are on this Hiroki space that we created.

102
00:07:11,250 --> 00:07:12,700
The containers that they call it.

103
00:07:12,810 --> 00:07:19,280
If I do Heroku run and then the command.

104
00:07:19,440 --> 00:07:25,230
So Heroku run LS is going to actually connect to the Heroku server and run the command.

105
00:07:25,230 --> 00:07:31,940
LS get the output and bring it back to me here in C running.

106
00:07:31,950 --> 00:07:34,770
LS attached a terminal every go.

107
00:07:34,860 --> 00:07:42,240
So this is all that we have on her book so I could look at node modules for instance let's say something

108
00:07:42,240 --> 00:07:43,830
wasn't working.

109
00:07:44,460 --> 00:07:47,240
I got an error saying that mongoose wasn't installed.

110
00:07:47,370 --> 00:07:58,470
Well I could verify Roku run LS node modules to see what node modules are installed and it will take

111
00:07:58,470 --> 00:08:01,920
a moment because it is doing this remotely.

112
00:08:01,920 --> 00:08:03,120
There we go and you can see.

113
00:08:03,130 --> 00:08:03,380
All right.

114
00:08:03,380 --> 00:08:09,170
So these are all the node modules installed Mongo there Mongoose is here.

115
00:08:09,240 --> 00:08:14,490
But if it wasn't here then and we would know OK we need to make sure we have it installed on this Heroku

116
00:08:14,910 --> 00:08:15,270
machine.

117
00:08:15,270 --> 00:08:23,830
And what we could do is also something like Heroku run NPM install mongoose dash dash.

118
00:08:23,830 --> 00:08:28,630
Save we don't need to do that but let's say that somehow it didn't get installed.

119
00:08:28,630 --> 00:08:29,800
We didn't have it in the package.

120
00:08:29,840 --> 00:08:34,340
Jason you can run code on that using Heroku run
