## Serving Nodefony Project

1. Developement Mode
2. Production Mode
3. Pre-Production Mode
4. Interactive Mode
5. Proxy Mode

## Serving Nodefony Project

#### Developement Mode

Serving a Nodefony project via an development server Starting Development Servers

    $ nodefony dev

    // TO STOP

    $ <ctrl-c>

Starting Development Servers in Debug Mode (-d)

    $ nodefony -d dev

    // TO STOP

    $ <ctrl-c>

## Serving Nodefony Project

#### Production Mode

## Serving Nodefony Project

#### Production Mode

Starting Servers Production (PM2)

    $ nodefony start # or nodefony prod

    ┌──────────────────┬────┬──────────────┬───────┬────────┬─────────┬───────────────────┬─────┬────────┬──────┬──────────┐
    │ App name         │ id │ mode         │ pid   │ status │ restart │ uptime            │ cpu │ memory │ user │ watching │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 0  │ cluster_mode │ 79361 │ online │ -       │ a few seconds ago │ 71% │ 56 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 1  │ cluster_mode │ 79362 │ online │ -       │ a few seconds ago │ 65% │ 54 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 2  │ cluster_mode │ 79365 │ online │ -       │ a few seconds ago │ 55% │ 51 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 3  │ cluster_mode │ 79372 │ online │ -       │ a few seconds ago │ 42% │ 45 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 4  │ cluster_mode │ 79377 │ online │ -       │ a few seconds ago │ 36% │ 39 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 5  │ cluster_mode │ 79382 │ online │ -       │ a few seconds ago │ 25% │ 33 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 6  │ cluster_mode │ 79387 │ online │ -       │ a few seconds ago │ 0%  │ 27 MB  │ cci  │ -        │
    ├──────────────────┼────┼──────────────┼───────┼────────┼─────────┼───────────────────┼─────┼────────┼──────┼──────────┤
    │ nodefony-starter │ 7  │ cluster_mode │ 79392 │ online │ -       │ a few seconds ago │ 0%  │ 21 MB  │ cci  │ -        │
    └──────────────────┴────┴──────────────┴───────┴────────┴─────────┴───────────────────┴─────┴────────┴──────┴──────────┘
     To see all logs use the command  nodefony logs
     Or use PM2  pm2 --lines 1000 logs

    // To stop
    $ nodefony stop

    // To kill pm2 Manager
    $ nodefony kill

## Serving Nodefony Project

#### Pre-Production Mode

##### Starting Servers Pre-Production

Usefull to check and use clusters

    $ nodefony preprod

    KERNEL SERVER Cluster : worker Environment : prod Debug :false

                                      _           __                                         _                    _
                  _ __     ___     __| |   ___   / _|   ___    _ __    _   _           ___  | |_    __ _   _ __  | |_    ___   _ __
                 | '_ \   / _ \   / _` |  / _ \ | |_   / _ \  | '_ \  | | | |  _____  / __| | __|  / _` | | '__| | __|  / _ \ | '__|
                 | | | | | (_) | | (_| | |  __/ |  _| | (_) | | | | | | |_| | |_____| \__ \ | |_  | (_| | | |    | |_  |  __/ | |
                 |_| |_|  \___/   \__,_|  \___| |_|    \___/  |_| |_|  \__, |         |___/  \__|  \__,_| |_|     \__|  \___| |_|
                                                                       |___/

              Version : 1.0.0 Platform : darwin Process : nodefony-starter PID : 86633

          KERNEL SERVER Cluster : worker Environment : prod Debug :false
    ...

## Serving Nodefony Project

#### Interactive Mode

##### Starting Servers Interactive

    $ nodefony # or npm start
             _   _    ___    ____    _____   _____    ___    _   _  __   __
            | \ | |  / _ \  |  _ \  | ____| |  ___|  / _ \  | \ | | \ \ / /
            |  \| | | | | | | | | | |  _|   | |_    | | | | |  \| |  \ V /
            | |\  | | |_| | | |_| | | |___  |  _|   | |_| | | |\  |   | |
            |_| \_|  \___/  |____/  |_____| |_|      \___/  |_| \_|   |_|

            Version : 4.2.0-beta.2 Platform : darwin Process : nodefony PID : 77661

            Thu Feb 28 2019 15:29:39 INFO nodefony : WELCOME PROJECT : nodefony-starter 1.0.0
            ?  Nodefony CLI :  (Use arrow keys)
            ❯ Start Servers Development
            Start Servers Pre-Production
            Start Servers Production
            Install Project
            Rebuild Project
            Generater
            Tools
            PM2 Tools
            Run Test
            --------
            Help
            Quit

## Serving Nodefony Project

#### PROXY Mode

#### Nginx

    # RENDER STATICS CDN
    server {
      listen       80;
      listen       443 ssl;
      server_name  static.nodefony.com;

      ssl_certificate  /path_to_nodefony/config/certificates/nodefony.fr/fullchain.pem;
      ssl_certificate_key /path_to_nodefony/config/certificates/nodefony.fr/privkey.pem;
      ssl_trusted_certificate /path_to_nodefony/config/certificates/nodefony.fr/fullchain.pem;

      location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|webm|htm|html|js|css|mp3|swf|ico|flv|woff.?|ttf)$ {
        access_log off;
        root /path_to_nodefony/web;
        expires 7d;
        add_header access-control-allow-origin  *;
      }
    }

    server {
      listen 80;

      server_name nodefony.com;

      set  $via  "1.0 nodefony nginx front";
      if ($http_via) {
      	set $via  "$http_via, 1.0 nodefony nginx front";
      }

      location / {
      	root /path_to_nodefony/web ;
      	proxy_pass http://nodefony.com:5151;
      	proxy_http_version 1.1;
      	proxy_pass_header Server;

      	proxy_set_header Upgrade $http_upgrade;
      	proxy_set_header Connection $connection_upgrade;
      	proxy_set_header Host $host;
      	proxy_set_header X-Forwarded-Proto $scheme;
      	proxy_set_header X-Forwarded-Port $server_port;
      	proxy_set_header X-Forwarded-Host $host;
      	proxy_set_header X-Forwarded-Server $host;
      	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header  Via  $via;
      	proxy_cache_bypass $http_upgrade;
      }

      location ~ \.(js|css|png|ico|jpg|jpeg|gif|ttf|font|map|woff.?|twig|txt|html|xml|json|mp3|wmv|avi|mpg|mpeg|mp4|webm|swf|flv)$ {
      	access_log off;
      	root /path_to_nodefony/web;
      	expires 7d;
      }
    }

    server {
      listen       443 ssl;

      server_name nodefony.com;

      ssl_certificate  /path_to_nodefony/config/certificates/nodefony.fr/fullchain.pem;
      ssl_certificate_key /path_to_nodefony/config/certificates/nodefony.fr/privkey.pem;
      ssl_trusted_certificate /path_to_nodefony/config/certificates/nodefony.fr/fullchain.pem;

      set  $via  "1.0 nodefony nginx front";
      if ($http_via) {
        set $via  "$http_via, 1.0 nodefony nginx front";
      }

      location / {
      	root /path_to_nodefony/web ;
      	proxy_pass https://nodefony.com:5152;
      	proxy_http_version 1.1;
      	proxy_pass_header Server;

      	proxy_set_header Upgrade $http_upgrade;
      	proxy_set_header Connection $connection_upgrade;

      	proxy_set_header Host $host;
      	proxy_set_header X-Forwarded-Proto $scheme;
      	proxy_set_header X-Forwarded-Port $server_port ;
      	proxy_set_header X-Forwarded-Host $host;
      	proxy_set_header X-Forwarded-Server $host;
      	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header  Via  $via;

      	proxy_cache_bypass $http_upgrade;
      }

      location ~ \.(js|css|png|ico|jpg|jpeg|gif|ttf|font|map|woff.?|twig|txt|html|xml|json|mp3|wmv|avi|mpg|mpeg|mp4|webm|swf|flv)$ {
      	root /path_to_nodefony/web;
      	expires 7d;
      	access_log off;
      }
    }