This is an todoList example built with
React
andRedux
to construct and display view inclient-server
. On the other hand, in back-endapi-server
, it handles all Restful requests and data depending onNode.js
,Express
andmongo
.
- pm2: Production process manager for Node.js apps with a built-in load balancer.
- node >= 6.0.0
- mongoDB
or
Docker
Now, there are two ways to boost the servers, one is running with docker
, and the other is using ur local node
and mongo
.
-
First you have to make sure to locate in directory
react-homework
.cd react-homework/
-
Then, you can execute following command to
build
docker image.docker build -t todo_list_server .
-
Finally, runs the process in isolated
container
.docker run -it --rm -P -p 8080:8080 -p 3000:3000 -p 27017:27017 --name todo_list_server -v $PWD:/usr/src/react-homework todo_list_server
-
As long as
MongoDB starting
, it means that you run the container sucessfully.
-
First of All, you have to install all
node_modules
in root and theservers
generally.npm i npm run install:all
-
make sure
mongo
is boosting and listening on port27017
. -
The simplest way to start and monitor
client-server
andapi-server
is using the following.npm run serve:all
docker exec -it todo_list_server /bin/bash
/
|-- /usr/src
| └-- react-homework # repo
|
|-- /tmp
| └-- docker-cmd.sh # initialized shell script when docker run
|
|-- /data/db # mongoDB folder
docker ps -a
As long as run the container, pm2
will boost servers automatically.
All you have to do is following the constrctions of pm2
to manipulate the servers.There is a cheatsheet about how to using pm2
below.
$ exit
docker stop todo_list_server
As long as stop container, it will be delete
immediately because of config --rm
.
Testing for api-server
npm run test:api
Testing for cli-server
npm run test:cli
- trevor: Your own mini Travis CI to run tests locally
Use all commands in pm2
you may know as long as to prepend ./pm2_remote
.
# Start all applications
npm run serve:all
# Start only client-server
npm run serve:cli
# Start only api-server
npm run serve:api
# Display all processes status
npm run list
# Stop all
npm run stop:all
# Restart all
npm run restart:all
# Reload all
npm run reload:all
# Delete all
npm run delete:all