Coder Social home page Coder Social logo

gondzo / ntl-solution-mechanism-guide Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elkhawajah/ntl-solution-mechanism-guide

0.0 2.0 2.0 66.18 MB

The Solution Mechanism Guide (SMG) is a tool to educate our scientists and managers about what tools are available for them to utilize in order to solve the challenges of spaceflight.

License: Apache License 2.0

JavaScript 53.57% Shell 0.38% CSS 15.37% HTML 30.49% PHP 0.20%

ntl-solution-mechanism-guide's Introduction

NASA Solutions Mechanism Guide

Application Technologies

  • Node.js 4.6.1
  • Nginx 1.10.2
  • MySQL 5.7
  • Git
  • Postman
  • Docker
  • Openshift

 

Docker deployment

Install docker and docker-compose with instructions from https://docs.docker.com/engine/installation/linux/docker-ce/centos/ and https://www.unixmen.com/docker-compose-install-centos-7/

Configuration

In the .env file you can configure these parameters:

  • DB_NAME=nasa-smg # name of the database
  • DB_USER=smg # database user
  • DB_PASSWORD=T0pcoder # database password
  • RESET_TABLES=false # weather to reset the db tables and data
  • DOWNLOADS_DIR=./downloads #path to a directory where files will be downloaded. Change this to a and existing directory outside the directory of this document
  • FILES_VERSION=1.0.1 # Files version
  • APP_PORT=3000 # application port

Running

To start the application just execute docker-compose up in the base directory. Application will be available on http://localhost:APP_PORT

Generating sample data

To generate sample data, after starting the application, in a new terminal run docker-compose exec app node generateRealFrontendData.js

Openshift deployment

  • Download the CLI tools, add the oc binary to path and log in to your openshift cluster. More details are available in your openshift Web console at help > Command Line Tools
  • Create a new project with oc new-project <project_name> --description="<description>" --display-name="<display_name>" (use any values for name, description and display name)
  • Create the application with oc process -f openshiftConfig.json | oc create -f -
  • To get app url, execute oc get routes
  • To execute a command in the container (generate test data) first execute oc get pods to get a list of active pods and note the NAME of the running pod. Then execute oc exec <POD_NAME> -c ntlapp node generateData.js

Application Setup

Log in to the the AWS server and change to the root user.

sudo su -

Install the prerequisites for setup.

yum install -y gcc git wget

Install Node.js 4.6.1 for Red Hat Enterprise Linux following the instructions at https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora. To summarise, run

curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -

then install Node.js 4.6.1 using

yum install -y nodejs

Install MySQL

Add the MySQL YUM repository

wget http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm

Next, install MySQL server.

yum install -y mysql-community-server

Once the server is installed successfully, start the service using service mysqld start. Obtain the auto-generated temporary password for the root account using grep 'temporary password' /var/log/mysqld.log.

Log in to mysql using the temporary password and change the password for the account.

mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'T0pcoder!';

Install GraphicsMagick

GraphicsMagick will be compiled from source. Download the latest source from ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.bz2

wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.bz2

Install bzip2 and other dependencies required to compile from source.

yum install -y bzip2 freetype-devel libpng-devel libjpeg-devel libtiff-devel libxml2-devel

Extract the GraphicsMagick source archive using tar -jxvf GraphicsMagick-LATEST.tar.bz2 and change the current directory to the extracted folder. Run the following commands to configure and build GraphicsMagick.

./configure --prefix=/usr
make
make install

Run gm in the shell to verify that the installation was successful.

 

Configurations

You can edit env-sample.sh to configure the application for your environment. You can set the following options:

  • DB_HOST : The host for MySQL server. (i.e. localhost)
  • DB_NAME : The MySQL database name. (i.e. nasa-smg)
  • DB_PORT : The port for MySQL server. (default 3306)
  • DB_USER : The username to login to MySQL. (default root)
  • DB_PASSWORD : The password to mysql server. (default empty password )
  • RESET_TABLES : The flag which indicates if the database tables should be created afresh. It will drop and create again all tables. Test data is not inserted. Tables will be reset each time you run node app. (default false)
  • DOWNLOADS_DIR : The path to directory where files are downloaded. Default to <app folder>/downloads.

In order to apply the environment variables, run . env-sample.sh

 

Database setup

You must create only empty database in MySQL server. Default database name is nasa-smg. Application will create all required tables.

To create the MySQL database, follow these steps.

  1. Run mysql -uroot -p at the shell and enter the password that you configured for the root user after installing MySQL.
  2. Execute CREATE DATABASE `nasa-smg`; after successful login with the MySQL client.

 

Deployment Instructions

Github code

  1. Clone the Github repository to your desired destination folder. For example, git clone https://github.com/NASA-Tournament-Lab/NTL-Solution-Mechanism-Guide www.
  2. Change the working directory to the cloned folder in your terminal.
  3. Run npm install.
  4. (optional) Generate some sample data, run node generateRealFrontendData.js.

Starting the app

Run node app in the working directory to start the application. You should now be able to access http://<url-to-aws-instance>:3000/ where <url-to-aws-instance> is the URL or IP address of the AWS instance the application was deployed to, and 3000 is the configured port.

Please make sure to enable access to the configured port by updating the instance's security policy (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html).

Nginx configuration (optional)

  1. Install nginx following the instructions at https://www.nginx.com/resources/wiki/start/topics/tutorials/install/. Use http://nginx.org/packages/rhel/7/x86_64/ as the configuration value for the repository baseurl.

  2. Replace the contents of /etc/nginx/conf.d/default.conf with the following configuration. Replace <ec2-host-name> with the host name of your EC2 instance, and replace 3000 (if required) with the configured application port.

    server {
        listen 80;
    
        server_name <ec2-host-name>;
    
        location / {
            proxy_pass http://127.0.0.1:3000;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for;
    
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    }
    ```
    
    
  3. Verify that the nginx configuration is valid by running nginx -t.

  4. Start nginx using service nginx start.

  5. If you encounter a 502 bad gateway error while trying to access the application using nginx, you may need to adjust the SELinux permissions for nginx. Run the following commands to set the required permissions.

    sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M nginx
    semodule -i nginx.pp
    

 

Mapping between $ legend and SMG cost characteristics values

Since cost characteristics values might change in database, we added a new configuration section under Admin portal (Configuration tab) i.e. http://:/admin/help#configuration . The section will list current cost characterstics values, and next to each value there is a drop down that contains three values $, $$ and $$$. By default all values are mapped to single dollar sign legend. When you are done with mapping, make sure to save changes.

 

Mapping between time legend and SMG cost characteristics values

Similar to $ mapping. You can map characteristic value to Low, Med or High. By default all values are mapped to Low.

ntl-solution-mechanism-guide's People

Contributors

akinwale avatar ambidv avatar elkhawajah avatar gondzo avatar jeffdoi avatar lstkz avatar nasarader avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.