Have Node.js and npm installed and working
- Install the dependencies with
npm installornpm ci(install exact dependencies as defined bypackage-lock.jsonfile) - Create and fill an
.envfile in the root of the project (see reference below for the keys) - Create and fill an
config.jsfile in the root of the project - (Optional) Compile the trajectory format converters with
npm run build. Otherwise, the trajectory endpoint will not be able to export from .bin to other formats. Chemfiles must be previously installed. - Start the server with
node index.jsor using a process manager like PM2 for example
To simply run an instance of the API you must enter the API git repository and run the following command:
npm run startIf you have an error related to process 9229 yo may solvie it like this:
kill -9 lsof -t -i:9229PM2 is a deamon which handles the spawn and monitoring of API instances. It is also useful to automatically respawn instances after failure.
In order to install pm2 run npm install pm2.
Once installed, head to the API directory and run 4 instances of it:
cd /path/to/api
pm2 start index.js -i 4 -n MDposit_API --node-args="--experimental-worker"If you need to stop the API then do the following:
pm2 delete MDposit_APINote that the API processes must be stopped and run again for new code to be effective after a 'git pull'.
| key | value | description |
|---|---|---|
| NODE_ENV | test or not defined |
to run a local fake mongo |
| DB_SERVER | <url> |
url of the db server |
| DB_PORT | number | port of the db server |
| DB_NAME | string | name of the db collection |
| DB_AUTH_USER | string | db user |
| DB_AUTH_PASSWORD | string | db password |
| DB_AUTHSOURCE | string | authentication db |
| LISTEN_PORT | number | port to query the API |
You may need to edit this file as well to customize your swagger documentation and define
how the API should behave depending on the requesting URL.
The file in the repository provides an explanation on every field and several examples.
Clone and install the chemfiles fork customized to support '.bin' format reading and streaming.
git clone https://github.com/d-beltran/chemfiles
cd chemfiles
mkdir build
cd build
cmake ..
make
sudo make install