Home

Awesome

FieldDBWebServer Build Status

================

Web Server for FieldDB corpus pages, and the project website.

Installation

Install Node.js

You need Node.js to run this webserver.

Mac:

$ brew install node

Linux:

$ sudo apt-get install nodejs

Windows:

You can download node from http://nodejs.org

Install dependancies

$ npm install

Configure

You can create a config/local.js file to point to the corpus service you want to contact. By default it contacts your localhost.

Run

To turn on the server:

$ npm run watch

To develop offline with fixture data:

$ OFFLINE=true npm start --offline

Then open https://localhost:3182 and accept the security certificate warning since you are developing locally with a self signed certificate.

To debug the client side code as well, in another tab turn on the webpack server:

$ node webpack.server.js

Then open https://localhost:3001/ and accept the security certificate warning since you are developing locally with a self signed certificate.


How to set up a production server

Running in production isn't much different from running while developing, except you will probably want to do some more customization of the configuration.

However, if you specified a port in the config, you might need someone with sudo privilges to open the port to the outside world so it will be accessible to the other machines who want to contact this service. Some universities and companies block non-standard ports so if you might have users who might be affected, you could request that someone with sudo priveleges set up a proxy such as Nginx or Apache to serve using a virtual host (eg https://www.example.org) rather than through a port (eg https://example.org:3182);

Configuration

You should copy the config/local.js to config/production.js

$ cp config/local.js config/production.js

Suggested changes:

Production mode is controlled by an environment variable. Here is how you would set the environment variables if you are running the server via a non-privileged user fielddb.

$ echo FIELDDB_HOME=/home/fielddb/fielddbhome >> ~/.bashrc
$ echo NODE_ENV=production >> ~/.bashrc

Finally turn on the service in a way that it will restart even in the case of errors:

$ gulp build
$ ./start_service

Development

This project uses server-side rendering with the React library so that component code can be shared between server and browser, as well as getting fast initial page loads and search-engine-friendly pages.

Try viewing the page source to ensure the HTML being sent from the server is already rendered (with checksums to determine whether client-side rendering is necessary).

Redux server side render is based on from mz026.

Stack:

Testing:

In development mode:

Assign static folder linking /assets to the folder above

In production mode:

Use a gulp task (gulp build) to handle it:

To test your production build:

$ gulp build
$ NODE_ENV=production npm start

Deployment:

To deploy this app to production environment:

$ npm run start:production

$./start_service

Release History

License

Licensed under the Apache, 2.0 licenses.