Windows Server Config - v22-appfactory/appfactory-wiki GitHub Wiki
The following is a summary of the steps needed to setup a Windows Server with Postgresql, the services application, and the web application. Further details can be found on the referenced pages.
-
Software Downloads and Installations
1a. NPM/Node
1b. Git (if working with repositories directly on the server)
1c. IIS
1d. IIS Rewrite plugin
1e. Postgresql (newest version available; version 10 or greater)
1f. PM2 -
Source Repositories
Either the cloned source repositories or a production version of the applications will be needed on the server.
2a. Services - https://github.com/gmarshall142/appfactory-services.git
NOTE: This repository also contains the SQL scripts for loading sample data for test and demo
2b. Web - https://github.com/gmarshall142/appfactory.git
2c. Migrations (used for loading the initial database) - https://github.com/gmarshall142/appfactory-migrations.git -
POSTGRES Database The setup of the postgres database is covered in the detail page: Postgresql on Windows
-
IIS
-
Two IIS websites were created: Appfactory and Web. The Appfactory application is used as a reverse-proxy which will redirect HTTPS requests to the services (running in PM2) and web applications. The Web website runs a web site from the \workspace\appfactory\dist directory.
NOTE: Depending on existing websites in IIS it may be necessary to create a virtual directory or alternate path. This will require adjustments to the VUE_APP_REST_HOST environment variable. -
The rewrite plugin needs to be installed in IIS.
4a. Application Website
Create a website called Appfactory using IIS and Certificates (Development Certificates may be used for testing). Add two URL rewrite rules for sending HTTPS requests to the Services and Web applications running on the localhost.
Creation of the application website is covered in the page: IIS Configuration4b. Web Website
Create a website called Web using HTTP and port 8080. Set the physical path to the 'appfactory/dist' directory.
Creation of the application website is covered in the page: IIS Configuration
- Set System Environment Variables
- NODE_ENV=production
- POSTGRES_HOST=IP of Postgresql server or localhost
- POSTGRES_NAME=appfactory
- POSTGRES_PORT=5432
- POSTGRES_USER=appuser
- POSTGRES_PSWD=Postgres appuser role password
- VUE_APP_PROTOCOL=https
- VUE_APP_REST_HOST=IP or Domain Name of this server/api
- VUE_APP_REST_PORT removed or empty
- VUE_APP_WEB_HOST=guest IP
- VUE_APP_WEB_PORT removed or empty
- VUE_APP_EMAIL=default user email
- VUE_APP_PSWD=default user password
- VUE_APP_MODE=DEV
- VUE_APP_LEVEL=debug
The Node projects can produce a production build by setting the NODE_ENV=production and running the project build:
set NODE_ENV=production
npm run build
This was done in both the services and the web project directories and populates the ./dist directory.
PM2 is a daemon process manager that will help you manage and keep your application online 24/7
npm install pm2@latest -g
The services application is run in PM2 in order to provide a Process Manager for running the Node application.
cd \workspace\services
pm2 start dist/index.js
- start cmd box with administrator rights
# setup appfactory
cd \workspace\appfactory
set NODE_ENV=production
npm run build
# setup services and start them
cd \workspace\services
set NODE_ENV=production
npm run build
set NODE_ENV=
node dist/index.js
- restart Appfactory and Web sites in IIS