generated from kookmin-sw/cap-template
[Server] Install and Running Guide
Hyeonwoo Kim edited this page May 31, 2022
·
50 revisions
Here, we explain how to deploy a baetaverse server
The following commands must be executed on the computer that will be used as the server.
Docker install guide (link)
Download Dockerfile from here
or
Clone BAETAVERSE project
# In your work directory
git clone https://github.com/kookmin-sw/capstone-2022-43.git
cd ./capstone-2022-43
# In Dockerfile located path
# Should needs sudo option
docker build -t <your docker image name> .
docker images
docker run -dit \
-p <YOUR ACCESS SERVER PORT NUMBER>:<YOUR SERVER PORT NUMBER IN CONTAINER> \
--name <YOUR DOCKER CONTAINER NAME> \
<YOUR DOCKER IMAGE NAME>
docker ps
docker exec -it <YOUR DOCKER CONTAINER NAME OR ID> bash
# Print simple server guide
cat README.txt
vi .env
PORT=_your_port_number_
JWT_OWNER_SECRET=_your_jwt_owner_secret_key_
JWT_FORWARDER_SECRET=_your_jwt_forwarder_secret_key_
HSCODE_SERVER_HOST=_your_hscode_server_host_url_
MYSQL_SERVER_HOST=_your_database_server_host_
MYSQL_SERVER_PORT=_your_database_server_port_numaber_
MYSQL_SERVER_USER=_your_database_access_user_name_
MYSQL_SERVER_PASSWORD=_your_database_access_user_password_
MYSQL_SERVER_DATABASE=_your_database_name_
If you done previous processes
Go on Build and Run Server
Go to the Node.js Website and Download current Windows version.
brew install node
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_17.x | sudo -E bash --
sudo apt-get install -y nodejs
npm -v //8.5.5
node -v //v17.8.0
# In your work directory
git clone https://github.com/kookmin-sw/capstone-2022-43.git
cd ./capstone-2022-43/server
Add your application configuration to your .env file in the capstone-2022-43/server
PORT=_your_port_number_
JWT_OWNER_SECRET=_your_jwt_owner_secret_key_
JWT_FORWARDER_SECRET=_your_jwt_forwarder_secret_key_
HSCODE_SERVER_HOST=_your_hscode_server_host_url_
MYSQL_SERVER_HOST=_your_database_server_host_
MYSQL_SERVER_PORT=_your_database_server_port_numaber_
MYSQL_SERVER_USER=_your_database_access_user_name_
MYSQL_SERVER_PASSWORD=_your_database_access_user_password_
MYSQL_SERVER_DATABASE=_your_database_name_
- Install node package Dependency
# For local machine
# Unnecessary process If you use docker image
npm install
- Build source files
# Build typescript files using tsc
# Create javascript files in 'dist' directory
npm run build
- Start with standard node command (Not recommended)
npm start
Ctrl+C # Stop server
- Start with nodemon package (For development)
# Unnecessary build process
# Run directly with typescript files
npm run dev
Ctrl+C # Stop server
- Start with PM2 (Recommended)
# For local machine
# Unnecessary process If you use docker image
npm install -g pm2
npm run deploy
pm2 stop server # Stop server
Server logs save in logs directory as a file about one day
If you want to know server logs about real time
We recommend to use PM2
# See logs in terminal
pm2 log
example image
# Trace logs with process information (ex. Memory usage, Heap size etc)
pm2 monit
example image
PM2 also offer real time server logs on their websites
You can see about PM2 on pm2.io