收集到的各种 nodejs,express,body-parse,angular,vue,react的各种小主题的资源的讲解

19 篇文章 0 订阅
12 篇文章 0 订阅


// nodejs,express,body-parse

_________________________________________________________________________________________________________________

Keeping API Routing Clean Using Express Routers

https://scotch.io/tutorials/keeping-api-routing-clean-using-express-routers


Speed up your RESTful API development in Node.js with Swagger

https://scotch.io/tutorials/speed-up-your-restful-api-development-in-node-js-with-swagger


Build a RESTful API Using Node and Express 4

https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4


Easy Node Authentication: Setup and Local (不错)

https://scotch.io/tutorials/easy-node-authentication-setup-and-local


Deploying a Node App to Digital Ocean (PM2,Nginx)

https://scotch.io/tutorials/deploying-a-node-app-to-digital-ocean


______________________

How to Host a Node.js App on Digital Ocean (forever start server.js) 

nodejs一般是当成一条用户命令执行的,当用户断开客户连接,运用也就停了,很烦人。如何让nodejs应用当成服务,在后台执行呢?

先说说平时我都是怎么部署程序的吧
1、最简单的办法,最常用的属nohup了,其实就是在后台执行进程,末尾加个&
$ nohup node app.js &
[zhoujie@ops-dev ~]$ nohup node /home/zhoujie/ops/app.js &
[1] 31490nohup: ignoring input and appending output to `nohup.out'

即此时程序已启动,直接访问即可,原程序的的标准输出被自动改向到当前目录下的nohup.out文件,起到了log的作用。该命令可以在你退出帐户/关闭终端之后继续运行相应的进程。nohup就是不挂起的意思( no hang up)。
该命令的一般形式为:nohup command &
  这个不太靠谱的样子,经常默默的进程在后台就挂了

2、但是,forever能做更多的事情,比如分别记录输出和错误日志,比如可以在js中作为api使用。
$ sudo npm install forever -g   #安装
$ forever start app.js          #启动
$ forever stop app.js           #关闭
$ forever start -l forever.log -o out.log -e err.log app.js   #输出日志和错误

One problem though, if you close your ssh session, npm will stop and your app will be offline. We need to use something that will ensure our app keeps running.

We'll use forever js. Stop you running app with Ctrl + C

root@ubuntu-512mb-nyc3-01:~/DO-nodejs# npm install -g forever
root@ubuntu-512mb-nyc3-01:~/DO-nodejs# forever start server.js
Going to <your_ip_address>:3000 on the browser should still be running your app. Our app will run forever.

Stopping the app should be intuitive
root@ubuntu-512mb-nyc3-01:~/DO-nodejs# forever stop server.js
That was the first approach. Let's look at the next one.

用PM2试试,比forever高端多了
3、PM2
使用它要先安装它,用root账号和全局模式安装一下:

npm install -g pm2

用它来启动程序(在当前目录下可以直接启动,pm2 start app.js --name uops)
命令整理一遍:
安装:npm install -g pm2
启动程序:pm2 start <app_name|id|all>
列举进程:pm2 list
退出程序:pm2 stop <app_name|id|all>
重起应用:pm2 restart
程序信息:pm2 describe id|all
监控:pm2 monit
实时集中log处理: pm2 logs
API:pm2 web (端口:9615 )


4. Docker Machine Approach





// Angular2/4/5

_________________________________________________________________________________________________________________



_________________________________________________________________________________________________________________



//Vue

_________________________________________________________________________________________________________________


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值