Git Product home page Git Product logo

hanfei's Introduction

node server based on express + mongodb + redis

开发环境

nvm install 4.4
nvm alias default 4.4

npm install -g gulp-cli #development
npm install -g pm2 #production

mongodb (3.2.8)
redis (3.2.1)

升级node

nvm install <new_version> --reinstall-packages-from=node #安装node并重装global packages
或者
nvm install <new_version>
nvm reinstall-packages <old_version>

修改配置启动新实例

# redis启动:
redis-server 6666.conf
# 以下列出的配置项都需认真检查核对,并根据自己的情况修改,其它未列出的配置可根据需要自行调整
daemonize yes
pidfile /data/tmp/redis_6666.pid
port 6666
bind 127.0.0.1

# 空闲超时自动关闭
timeout 3600

# 日志文件
logfile /data/log/redis6666.log

# rdb持久化
dbfilename dump6666.rdb
dir /data/redis

# aof持久化,一般不用打开
appendonly no
appendfilename "appendonly6666.aof"
appendfsync no

# 慢日志
slowlog-log-slower-than 100000
slowlog-max-len 65536

目录结构

├── README.md
├── RELEASE.md #重大发布的发布日志
├── app.js #http服务器入口
├── auth #认证相关
├── common #通用组件
├── conf #配置文件,mongo,redis服务器启动所使用的配置文件统一管理
├── config #根据NODE_ENV加载的不同配置文件
├── controllers
├── gulpfile.js #gulp serve自动重启服务器
├── models #model设计
├── package.json
├── routes #路由表
├── scripts #脚本
└── services #业务逻辑代码

日志格式

morgan('combined')的基础上,将日期格式从[:date[clf]]改为[:date[iso]],并新增加了:response-time这一列

:remote-addr - :remote-user [:date[iso]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" :response-time ms

hanfei's People

Contributors

lutaoact avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.