Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,706 members, 7,802,102 topics. Date: Friday, 19 April 2024 at 09:15 AM

Node Js Gurus @nswer This Biko - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Node Js Gurus @nswer This Biko (3230 Views)

Free PHP, Node js ,Mongo db, Angular And C# Proje Source Code With Documentation / React + Node Js : Fullstack Web Development Training / Lets Learn React Native,javascript,react Js And Node Js Together(alimosho LGA) (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Node Js Gurus @nswer This Biko by crunchyDope(m): 7:38am On Sep 10, 2020
am just learning node and d whole thing looks like building a car(server) from scratch

question 1

with php u just write your scripts and all link pointing at that direction just works!
like so =>www,example,com/test.php

but would dat work in json node? cos it seems all the coding is done in this app.js file only!

question 2

would i still go the terminal to start the app? in a live server?
is that reliable?
what if the system reboots? hw do i know? isn't dat too much work?

sorry but not sorry for any grammatical errors, English is not my mother's tongue
Re: Node Js Gurus @nswer This Biko by cixak95211: 9:57am On Sep 10, 2020
crunchyDope:
am just learning node and d whole thing looks like building a car(server) from scratch

question 1

with php u just write your scripts and all link pointing at that direction just works!
like so =>www,example,com/test.php

but would dat work in json node? cos it seems all the coding is done in this app.js file only!

question 2

would i still go the terminal to start the app? in a live server?
is that reliable?
what if the system reboots? hw do i know? isn't dat too much work?

sorry but not sorry for any grammatical errors, English is not my mother's tongue

1. Nodejs is meant for server-side applications . . although you can write a bit of frontend too, using stuffs like hbs and pug. But its primary focus is server-side code. Server side applications dont have that www.example.com/something where it displays a page. Nope!
Yes, they might have a URL, but its more like api.example.com/v1
So you will need a frontend to marry the backend (node js) for a complete application . . Thats what is popularly referred to as a microservice architecture. as against Laravel for instance where both frontend and backend are sitting inside one application, Monolithic architecture.
You can still use Laravel to write APis only, story for another day!

2. This question is now damn funny. Show truly you just started out, No shame in it, brov! As a professional software engineer, you will learn stuffs like "fault tolerance" which means what happens if I'm asleep and my server crashes? who will restart it? A fault tolerant app will restart itself. You will learn stuffs like process management. One good example is PM2. Google it, You will learn a little bit of server adminstration and what it means to deamonize an app [make it a service]. A service will always restart itself as long as it was enabled. Servers in production dont reboot.
They can be online for 1000000 years without rebooting. Even your PC can be online for so long too, but eventually nepa will "take light"
Servers are online 24/7. Google pictures of servers and see for yourself what they look like. And yes, you need to be very good with the terminal too.

One step at a time. Learn javascript first, then node
then a little bit of cloud engineering, which will teach you most stuffs in server administration
Then take a deep dive into building applications that scale, and mission-critical apps . .[app that shoudl nevr go down, even during updates for 1 second]. Good luck.

9 Likes 2 Shares

Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 10:20am On Sep 10, 2020
cixak95211:


1. Nodejs is meant for server-side applications . . although you can write a bit of frontend too, using stuffs like hbs and pug. But its primary focus is server-side code. Server side applications dont have that www.example.com/something where it displays a page. Nope!
Yes, they might have a URL, but its more like api.example.com/v1
So you will need a frontend to marry the backend (node js) for a complete application . . Thats what is popularly referred to as a microservice architecture. as against Laravel for instance where both frontend and backend are sitting inside one application, Monolithic architecture.
You can still use Laravel to write APis only, story for another day!

2. This question is now damn funny. Show truly you just started out, No shame in it, brov! As a professional software engineer, you will learn stuffs like "fault tolerance" which means what happens if I'm asleep and my server crashes? who will restart it? A fault tolerant app will restart itself. You will learn stuffs like process management. One good example is PM2. Google it, You will learn a little bit of server adminstration and what it means to deamonize an app [make it a service]. A service will always restart itself as long as it was enabled. Servers in production dont reboot.
They can be online for 1000000 years without rebooting. Even your PC can be online for so long too, but eventually nepa will "take light"
Servers are online 24/7. Google pictures of servers and see for yourself what they look like. And yes, you need to be very good with the terminal too.

One step at a time. Learn javascript first, then node
then a little bit of cloud engineering, which will teach you most stuffs in server administration
Then take a deep dive into building applications that scale, and mission-critical apps . .[app that shoudl nevr go down, even during updates for 1 second]. Good luck.

thanks boss, fully understood.

1 Like

Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 10:22am On Sep 10, 2020
cixak95211:

which means the app instance is what handles all the url?
Re: Node Js Gurus @nswer This Biko by cixak95211: 11:59am On Sep 10, 2020
crunchyDope:


which means the app instance is what handles all the url?

The url in this case, a url to where the application resides, usually localhost, if you are developing
but in production, localhost will bind to the server ip address, which can in turn be bound to a custom domain
so e.g . localhost:4000/api => 34.32.12.XX/api => nairaland.com/api
so using nairaland as an example, if its a microservice, its gonna have at least 2 urls . . it could even be 50 . . but lets stick to the minimum 2
nairaland.com, which is what you will see and type, and that inturn will make a request to e..g. api.nairaland.com or nairaland.co/api [the owner chooses the style they like] . . the 2nd url is the server which responds with required data, and the data is shown to you on your screen
or allows you to do something, eg. login.
Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 1:01pm On Sep 10, 2020
cixak95211:


The url in this case, a url to where the application resides, usually localhost, if you are developing
but in production, localhost will bind to the server ip address, which can in turn be bound to a custom domain
so e.g . localhost:4000/api => 34.32.12.XX/api => nairaland.com/api
so using nairaland as an example, if its a microservice, its gonna have at least 2 urls . . it could even be 50 . . but lets stick to the minimum 2
nairaland.com, which is what you will see and type, and that inturn will make a request to e..g. api.nairaland.com or nairaland.co/api [the owner chooses the style they like] . . the 2nd url is the server which responds with required data, and the data is shown to you on your screen
or allows you to do something, eg. login.

thanks so much!!!!
Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 1:07pm On Sep 10, 2020
cixak95211:


last question for now boss, if major company like uber and co uses node, how do they handle the service when they want to push an update? like they just ^C twice and npm start?
just even in dev mode it is stressful, n easy solution?
Re: Node Js Gurus @nswer This Biko by cixak95211: 1:15pm On Sep 10, 2020
crunchyDope:


last question for now boss, if major company like uber and co uses node, how do they handle the service when they want to push an update? like they just ^C twice and npm start?

Nah, far from that . . thats for when you're writing codes on ur laptop. As part of your learning, you will venture into something called CI/CD. Pls google the full meaning. simply put, its a workflow that allows for continuous integration. I'll give u a case study of our own flow.
We have 6 servers in AWS and they are always online. Once we make an update to github, it automatically pushes itself to AWS but code is not deployed yet, that's only a staging environment. It gives us a unque environment to test and test. When satisfied, we push to production. I like to do it manually, when am bored and here is what i do.
1. log into server via ssh
2. turn on bastion host, and update it to mirror staging environment, which as the latest update..
3. We use nginx as a reverse proxy server . . . google what a reverse proxy is for claririfcation, it might not make sense tho for now
4. Open nginx config and reroute all traffic to bastion host.
5. Do a hot reload. A hot reload will make sure connections are not dropped, cos users are online, but it will switch all users automatically to the new version. You wont even notice.
6. Update main application.
7. Open nginx config again and reroute all traffic to main app
8. Do a hot reload once more.
9. Shut down bastion host and exit out of ssh server.

For our API, its running under PM2 process manager, and we have a flag called "watching" . . which means when there is a change, it will auto build and deploy itself and do a hot reload. It will do exactly the same thing I listed above but this time automatically. Its a very long story and might not make sense now. But trust me, your time will come.

6 Likes

Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 1:20pm On Sep 10, 2020
cixak95211:


Nah, far from that . . thats for when you're writing codes on ur laptop. As part of your learning, you will venture into something called CI/CD. Pls google the full meaning. simply put, its a workflow that allows for continuous integration. I'll give u a case study of our own flow.
We have 6 servers in AWS and they are always online. Once we make an update to github, it automatically pushes itself to AWS but code is not deployed yet, that's only a staging environment. It gives us a unque environment to test and test. When satisfied, we push to production. I like to do it manually, when am bored and here is what i do.
1. log into server via ssh
2. turn on bastion host, and update it to mirror staging environment, which as the latest update..
3. We use nginx as a reverse proxy server . . . google what a reverse proxy is for claririfcation, it might not make sense tho for now
4. Open nginx config and reroute all traffic to bastion host.
5. Do a hot reload. A hot reload will make sure connections are not dropped, cos users are online, but it will switch all users automatically to the new version. You wont even notice.
6. Update main application.
7. Open nginx config again and reroute all traffic to main app
8. Do a hot reload once more.
9. Shut down bastion host and exit out of ssh server.

For our API, its running under PM2 process manager, and we have a flag called "watching" . . which means when there is a change, it will auto build and deploy itself and do a hot reload. It will do exactly the same thing I listed above but this time automatically. Its a very long story and might not make sense now. But trust me, your time will come.
too rich for my blood..Lol.. u b truly guru!

so its like so {code} => {dummy app} <= {users} {main app}
code => {main app}
users => {main app} <so fast the users wont notice>

wow.. anyways for local host development , no hot reloading?
Re: Node Js Gurus @nswer This Biko by cixak95211: 1:28pm On Sep 10, 2020
crunchyDope:

too rich for my blood..Lol.. u b truly guru!

so its like so {code} => {dummy app} <= {users} {main app}
code => {main app}
users => {main app} <so fast the users wont notice>

wow.. anyways for local host development , no hot reloading?

It not about being fast the users wont notice. It utilizes what we call 'graceful shutdown". When you do a hot reload, imagine you have 10 users on yur platform, and 6 have sent a request to login at exactly when you did that reload. A cold reload will kill nginx, and they will recieve an error page.
For A hot reload [because nginx uses master => slave workers]., the master will see that there are 6 pending request, and it will fulfil those requests first. The requests are handled by slaves, Then it will command the slaves to shutdown. Any new request (remember the other 4) will be routed to the new updated application. So in summary, it waits to fulfil any pending request before killing the processes.
Read more on "worker thread and processes". its is very fundamental to building a performant application.
For your local dev, u dont need any hot reload, waste of time. If you cant type npm run this, npm run that all the time
just add shortcuts to ur terminal or console's profile e.g.

A few of mine, i have like hundreds of those literally,
git push origin HEAD --force-with-lease = gpf
npm run start:dev = dev
yarn install = yi

you get the idea, right?

Then use autocomplete for your terminals, so yo dont have to remember even the shortcuts, cos u wil forget after some time.

1 Like

Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 1:37pm On Sep 10, 2020
cixak95211:


It not about being fast the users wont notice. It utilizes what we call 'graceful shutdown'. When you do a hot reload, imagine you have 10 users on yur platform, and 6 have sent a request to login at exactly when you did that reload. A cold reload will kill nginx, and they will recieve an error page.
For A hot reload [because nginx uses master => slave workers]., the master will see that there are 6 pending request, and it will fulfil those requests first. The requests are handled by slaves, Then it will command the slaves to shutdown. Any new request (remember the other 4) will be routed to the new updated application. So in summary, it waits to fulfil any pending request before killing the processes.
Read more on "worker thread and processes". its is very fundamental to building a performant application.
For your local dev, u dont need any hot reload, waste of time. If you cant type npm run this, npm run that all the time
just add shortcuts to ur terminal or console's profile e.g.

A few of mine, i have like hundreds of those literally,
git push origin HEAD --force-with-lease = gpf
npm run start:dev = dev
yarn install = yi

you get the idea, right?

Then use autocomplete for your terminals, so yo dont have to remember even the shortcuts, cos u wil forget after some time.




nice, thanks boss!!!
you re too good!!!
Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 1:39pm On Sep 10, 2020
cixak95211:


i think am going to use vs and just do the reload
thanks for the tutorial and the exposure.
Re: Node Js Gurus @nswer This Biko by cixak95211: 1:45pm On Sep 10, 2020
crunchyDope:


nice, thanks boss!!!
you re too good!!!

You're welcome, glad to have been of help.
Re: Node Js Gurus @nswer This Biko by Xperienx(m): 11:31am On Sep 12, 2020
cixak95211:


Nah, far from that . . thats for when you're writing codes on ur laptop. As part of your learning, you will venture into something called CI/CD. Pls google the full meaning. simply put, its a workflow that allows for continuous integration. I'll give u a case study of our own flow.
We have 6 servers in AWS and they are always online. Once we make an update to github, it automatically pushes itself to AWS but code is not deployed yet, that's only a staging environment. It gives us a unque environment to test and test. When satisfied, we push to production. I like to do it manually, when am bored and here is what i do.
1. log into server via ssh
2. turn on bastion host, and update it to mirror staging environment, which as the latest update..
3. We use nginx as a reverse proxy server . . . google what a reverse proxy is for claririfcation, it might not make sense tho for now
4. Open nginx config and reroute all traffic to bastion host.
5. Do a hot reload. A hot reload will make sure connections are not dropped, cos users are online, but it will switch all users automatically to the new version. You wont even notice.
6. Update main application.
7. Open nginx config again and reroute all traffic to main app
8. Do a hot reload once more.
9. Shut down bastion host and exit out of ssh server.

For our API, its running under PM2 process manager, and we have a flag called "watching" . . which means when there is a change, it will auto build and deploy itself and do a hot reload. It will do exactly the same thing I listed above but this time automatically. Its a very long story and might not make sense now. But trust me, your time will come.

This answer in beyond the scope of the OP. He's absolute and saying all these could even confuse him the more.
Re: Node Js Gurus @nswer This Biko by cixak95211: 11:49am On Sep 12, 2020
Xperienx:


This answer in beyond the scope of the OP. He's absolute and saying all these could even confuse him the more.

True that, but his curiosity kept going deeper and i just had to oblige him, and even told him it would not make sense now
but it will surely do, if he keeps on keeping on.
Re: Node Js Gurus @nswer This Biko by Nobody: 12:21pm On Sep 12, 2020
cixak95211:


1. Nodejs is meant for server-side applications . . although you can write a bit of frontend too, using stuffs like hbs and pug. But its primary focus is server-side code. Server side applications dont have that www.example.com/something where it displays a page. Nope!
Yes, they might have a URL, but its more like api.example.com/v1
So you will need a frontend to marry the backend (node js) for a complete application . . Thats what is popularly referred to as a microservice architecture. as against Laravel for instance where both frontend and backend are sitting inside one application, Monolithic architecture.
You can still use Laravel to write APis only, story for another day!

2. This question is now damn funny. Show truly you just started out, No shame in it, brov! As a professional software engineer, you will learn stuffs like "fault tolerance" which means what happens if I'm asleep and my server crashes? who will restart it? A fault tolerant app will restart itself. You will learn stuffs like process management. One good example is PM2. Google it, You will learn a little bit of server adminstration and what it means to deamonize an app [make it a service]. A service will always restart itself as long as it was enabled. Servers in production dont reboot.
They can be online for 1000000 years without rebooting. Even your PC can be online for so long too, but eventually nepa will "take light"
Servers are online 24/7. Google pictures of servers and see for yourself what they look like. And yes, you need to be very good with the terminal too.

One step at a time. Learn javascript first, then node
then a little bit of cloud engineering, which will teach you most stuffs in server administration
Then take a deep dive into building applications that scale, and mission-critical apps . .[app that shoudl nevr go down, even during updates for 1 second]. Good luck.

You've said it all. I laughed when I read the second question though. Production servers very rarely reboot (except when using a PaaS provider) except server providers like Heroku but even Heroku has a json file it runs like a daemon everytime the app restarts. So that problem is solved. On a production server on a service like AWS you probably have automation sorted out as part of the software infrastructure. Thanks for this insightful answer.

May I know your stack?
Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 12:52pm On Sep 12, 2020
DanTheGeek:


Xperienx:


you guys are still using the word rarely which means not "impossible".. so this is how i sleep knowing my crawlers might one day fail grin

Re: Node Js Gurus @nswer This Biko by cixak95211: 2:16pm On Sep 12, 2020
crunchyDope:

you guys are still using the word rarely which means not "impossible".. so this is how i sleep knowing my crawlers might one day fail grin

You worry too much about the less important stuffs. There are more important stuffs to worry about e.g. how to scale up and down and keep costs low. Well to answer your questions. If you want your app to always stay online 24/7/365 even in the event of a terrorist attack or nuclear bomb blast, then you need to invest in "geo redundancy". Servers are divided into geographical location and zones. e.g. Eu-west-2 which stand for London in AWS [amazon] and Us-central-1 which stands for Iowa [Google]
Those are now divided into zones, i.e. cities which are at least 100km apart from each other e.g. eu-west2-a, eu-west-2b, eu-west-3b . . repeat for us-central-1a u get the idea . . if you wanna make your app geo-redundant, you will need to deploy your app in multiple servers across different zones and countries. you might deploy it in 12 countries across the world . I hope you have money for that, cos the bill will be in hundreds of thousands of dollars each month.
SO if Russia goes down, USA is stil online, ur app is still working. If CHina blows USA, the one is London is still workin . . London has fallen, then the one in South Africa is stil online . . if the whole 12 countries go down, then you know its the end of the world and nobody would be using the app anyways when we are all dead.
Now the question is? Can yo afford it? So better stick to a single server, and when you make cash, like Jeff and Mark, you can even create your own server farms which is what they all did. Goodluck

3 Likes

Re: Node Js Gurus @nswer This Biko by cixak95211: 2:19pm On Sep 12, 2020
DanTheGeek:


You've said it all. I laughed when I read the second question though. Production servers very rarely reboot (except when using a PaaS provider) except server providers like Heroku but even Heroku has a json file it runs like a daemon everytime the app restarts. So that problem is solved. On a production server on a service like AWS you probably have automation sorted out as part of the software infrastructure. Thanks for this insightful answer.

May I know your stack?

Software Engineer . . . MEAN, PERN, but more of MERN
Cloud Engineer [GCP, AWS]

1 Like

Re: Node Js Gurus @nswer This Biko by Nobody: 2:24pm On Sep 12, 2020
cixak95211:


Software Engineer . . . MEAN, PERN, but more of MERN
Cloud Engineer [GCP, AWS]

Great. Nice meeting another JavaScript ninja in the house. I do JavaScript too but MERN also some PHP, Python and Golang.
Re: Node Js Gurus @nswer This Biko by cixak95211: 2:29pm On Sep 12, 2020
DanTheGeek:


Great. Nice meeting another JavaScript ninja in the house. I do JavaScript too but MERN also some PHP, Python and Golang.

I was an early adopter of php, during the hay-days of Zend and Symfony . . . But have since hung my boots
I wouldnt touch php with a 100-foot pole now. We have both gone our separate ways.

1 Like

Re: Node Js Gurus @nswer This Biko by Nobody: 2:33pm On Sep 12, 2020
cixak95211:


I was an early adopter of php, during the hay-days of Zend and Symfony . . . But have since hung my boots
I wouldnt touch php with a 100-foot pole now. We have both gone our separate ways.

Lmao. I plan to switch to full stack JS very soon too.
Re: Node Js Gurus @nswer This Biko by crunchyDope(m): 6:15pm On Sep 12, 2020
cixak95211:


You worry too much about the less important stuffs. There are more important stuffs to worry about e.g. how to scale up and down and keep costs low. Well to answer your questions. If you want your app to always stay online 24/7/365 even in the event of a terrorist attack or nuclear bomb blast, then you need to invest in "geo redundancy". Servers are divided into geographical location and zones. e.g. Eu-west-2 which stand for London in AWS [amazon] and Us-central-1 which stands for Iowa [Google]
Those are now divided into zones, i.e. cities which are at least 100km apart from each other e.g. eu-west2-a, eu-west-2b, eu-west-3b . . repeat for us-central-1a u get the idea . . if you wanna make your app geo-redundant, you will need to deploy your app in multiple servers across different zones and countries. you might deploy it in 12 countries across the world . I hope you have money for that, cos the bill will be in hundreds of thousands of dollars each month.
SO if Russia goes down, USA is stil online, ur app is still working. If CHina blows USA, the one is London is still workin . . London has fallen, then the one in South Africa is stil online . . if the whole 12 countries go down, then you know its the end of the world and nobody would be using the app anyways when we are all dead.
Now the question is? Can yo afford it? So better stick to a single server, and when you make cash, like Jeff and Mark, you can even create your own server farms which is what they all did. Goodluck

Iolz!!!! noted boss.
Re: Node Js Gurus @nswer This Biko by tensazangetsu20(m): 8:59pm On Sep 12, 2020
cixak95211:


I was an early adopter of php, during the hay-days of Zend and Symfony . . . But have since hung my boots
I wouldnt touch php with a 100-foot pole now. We have both gone our separate ways.
I was learning node but men PHP seems to have more jobs even in the freelancing side of things. On Upwork at any given point in time they are 500 nodejs jobs and over 8000 PHP jobs. WordPress which is run by PHP has over 10000 jobs. PHP also powers 83 percent of websites globally. WordPress 32 percent and nodejs 0.9 percent. Languages like scala and Perl even have more coverage than Nodejs. Java and c# have way way more coverage too than Nodejs.
Re: Node Js Gurus @nswer This Biko by cixak95211: 10:48pm On Sep 12, 2020
^^ Hell yea, no disputing of those facts. Which in turn has led to too many adulterated engineers . . .A former CTO once told me, Nodejs is the language of the future, invest in your future now. Maybe that an exaggeration, but we all know the "20k gang", as I like to call them, both within and outside Nairaland, all gained their founding in php and it's gang of companies e.g. wordpress.

2 Likes

Re: Node Js Gurus @nswer This Biko by tensazangetsu20(m): 10:56pm On Sep 12, 2020
cixak95211:
^^ Hell yea, no disputing of those facts. Which in turn has led to too many adulterated engineers . . .A former CTO once told me, Nodejs is the language of the future, invest in your future now. Maybe that an exaggeration, but we all know the "20k gang", as I like to call them, both within and outside Nairaland, all gained their founding in php and it's gang of companies e.g. wordpress.
I don't think those 20k gang know how to even declare variables in JavaScript. I met a computer science graduate from a university in the south east. He also builds websites WordPress websites and claims to know HTML, CSS, JavaScript, bootstrap and PHP. I asked him to tell me how they declare variables in PHP and he said that the question was too big for him. Even here on nairaland when they post that crap try interrogating their knowledge. They don't even know the basics. Wasn't it on this section someone was asking for help with editing a HTML template and be was advertising 20k websites on his signature.
Re: Node Js Gurus @nswer This Biko by cixak95211: 11:28pm On Sep 12, 2020
Lmao, i remember that dude. It was funny as hell.
Re: Node Js Gurus @nswer This Biko by sonofthunder: 4:08pm On Sep 13, 2020
tensazangetsu20:

I don't think those 20k gang know how to even declare variables in JavaScript. I met a computer science graduate from a university in the south east. He also builds websites WordPress websites and claims to know HTML, CSS, JavaScript, bootstrap and PHP. I asked him to tell me how they declare variables in PHP and he said that the question was too big for him. Even here on nairaland when they post that crap try interrogating their knowledge. They don't even know the basics. Wasn't it on this section someone was asking for help with editing a HTML template and be was advertising 20k websites on his signature.
Lol
Re: Node Js Gurus @nswer This Biko by codeigniter(m): 12:47am On Sep 15, 2020
cixak95211:


Nah, far from that . . thats for when you're writing codes on ur laptop. As part of your learning, you will venture into something called CI/CD. Pls google the full meaning. simply put, its a workflow that allows for continuous integration. I'll give u a case study of our own flow.
We have 6 servers in AWS and they are always online. Once we make an update to github, it automatically pushes itself to AWS but code is not deployed yet, that's only a staging environment. It gives us a unque environment to test and test. When satisfied, we push to production. I like to do it manually, when am bored and here is what i do.
1. log into server via ssh
2. turn on bastion host, and update it to mirror staging environment, which as the latest update..
3. We use nginx as a reverse proxy server . . . google what a reverse proxy is for claririfcation, it might not make sense tho for now
4. Open nginx config and reroute all traffic to bastion host.
5. Do a hot reload. A hot reload will make sure connections are not dropped, cos users are online, but it will switch all users automatically to the new version. You wont even notice.
6. Update main application.
7. Open nginx config again and reroute all traffic to main app
8. Do a hot reload once more.
9. Shut down bastion host and exit out of ssh server.

For our API, its running under PM2 process manager, and we have a flag called "watching" . . which means when there is a change, it will auto build and deploy itself and do a hot reload. It will do exactly the same thing I listed above but this time automatically. Its a very long story and might not make sense now. But trust me, your time will come.

I have my forum running on AWS and I do things manually, though I use supervisor instead of pm2 cause i am using python.

but I don't touch nginx

I push the code to github

then I ssh into the server

I go to my Ubuntu root directory
I activate my venv
cd to the project
pull the new changes
if there is any change in staticfiles, I recollect them
lastly, I restart my supervisor

and my forum is updated
this does not take up to 10min of my time. maybe because I am the only one writing code on the repo

though I am not a devops engineer but I will like to know how to automate with CI/CD in d future.

I started with node js. but I don't do node js anymore cos of it's callback, hell to debug, immature framework like express js though it is getting better, difficult orm like mongoose, to authenticate na war in nodejs. well some of u might say it not that difficult, but as a self taught learning from free materials, it is very difficult. the only advantage I missed in nodejs is it events and asynchronous native which I can simulate in python with asyncio. in short if I didn't switch to python on web I would have stayed with reactjs with hooks! lol. I prefer flask for APIs and small SSR site, Django for big SSR site like my forum, though I can still write APIs or SSR site with ejs or handlebars in nodejs, cos I spent more time with that js runtime than flask or django

1 Like

Re: Node Js Gurus @nswer This Biko by Taofeekdboy(m): 5:19am On Sep 15, 2020
codeigniter:


I have my forum running on AWS and I do things manually, though I use supervisor instead of pm2 cause i am using python.

but I don't touch nginx

I push the code to github

then I ssh into the server

I go to my Ubuntu root directory
I activate my venv
cd to the project
pull the new changes
if there is any change in staticfiles, I recollect them
lastly, I restart my supervisor

and my forum is updated
this does not take up to 10min of my time. maybe because I am the only one writing code on the repo

though I am not a devops engineer but I will like to know how to automate with CI/CD in d future.

I started with node js. but I don't do node js anymore cos of it's callback, hell to debug, immature framework like express js though it is getting better, difficult orm like mongoose, to authenticate na war in nodejs. well some of u might say it not that difficult, but as a self taught learning from free materials, it is very difficult. the only advantage I missed in nodejs is it events and asynchronous native which I can simulate in python with asyncio. in short if I didn't switch to python on web I would have stayed with reactjs with hooks! lol. I prefer flask for APIs and small SSR site, Django for big SSR site like my forum, though I can still write APIs or SSR site with ejs or handlebars in nodejs, cos I spent more time with that js runtime than flask or django
From a Django developer as well, I have been working closely with node js recently and if you are coming from Django rest framework then node js and express will be something really easy to work with provided your Javascript understanding is very solid. Based on the authentication, I work closely with JWT because passport authentication to me is a little bit tedious and working with MERN stack makes it easy to work with JWT authentication. I will release a project I am working on it soon.
Re: Node Js Gurus @nswer This Biko by codeigniter(m): 11:06am On Sep 15, 2020
Taofeekdboy:

From a Django developer as well, I have been working closely with node js recently and if you are coming from Django rest framework then node js and express will be something really easy to work with provided your Javascript understanding is very solid. Based on the authentication, I work closely with JWT because passport authentication to me is a little bit tedious and working with MERN stack makes it easy to work with JWT authentication. I will release a project I am working on it soon.

yes, coming from drf makes it easier because u will have understood the concepts which is the most important thing, but drf takes care of all the manual work, e.g I use permission based class and add an auth library at the settings which will depend on drf token table, drf is very easy if u are using class based view. jwt is easier than password but when I was doing MERN, i read that the token doesn't expire and if another person access ur device they can easily copy the token. I built a personalized API auth for flask I use decorators to make sure it can be used by anyone. i might release to make developer more lazy! lol. why did u switch to node.js, I would like to know I am very u will miss Django orm, except if u use mongoose
Re: Node Js Gurus @nswer This Biko by cixak95211: 1:30pm On Sep 15, 2020
codeigniter:


yes, coming from drf makes it easier because u will have understood the concepts which is the most important thing, but drf takes care of all the manual work, e.g I use permission based class and add an auth library at the settings which will depend on drf token table, drf is very easy if u are using class based view. jwt is easier than password but when I was doing MERN, i read that the token doesn't expire and if another person access ur device they can easily copy the token. I built a personalized API auth for flask I use decorators to make sure it can be used by anyone. i might release to make developer more lazy! lol. why did u switch to node.js, I would like to know I am very u will miss Django orm, except if u use mongoose

Authentication, like you said, is one of the hardest things in Nodejs, especially if you want to do it properly. Most people just whip up a JWT -based token and thats' all. but it comes with a problem, e.g how to invalidate a token. The token does expire. But the problem is what if user permissions are changed before the token expires e..g downgrading a user. If the user has saved the token somehow, they can still use it access to former [now obsolete] permissions.
So you must always 1.) get fresh user's tats from the DB at authenticated request and NOT RELY on what the jwt says, even if yes, you did sign it and it was not tampered i.e. the signature is intact and 2.) implement an in-memory store like Memcached and Redis to keep blacklisted tokens till they expire.,,, a very fast way to invalidate tokens. It doesn end there.
You should 3.) implement refresh tokens + access token architecture, this way it's easy to mitigate an attack when somebody steals your token or logs in from another device and/or ip address, however you want it.
Stages #2 and especially #3 is where it gets pretty difficult for newbies. But as with other things in life, perfections comes via practice.

(1) (2) (3) (Reply)

Simple Logic!think U Can Crack This? / How To Program Outseal Arduino PLC / We Are Developing Yoruba Dictionary, What Do You Think?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 124
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.