Location Framework configurations in File System

Location : ./config
config/
├── certificates
│   ├── ca
│   ├── ca_intermediate
│   ├── client
│   └── server
├── config.yml
├── openssl
│   ├── ca
│   └── ca_intermediate
└── pm2.config.js
        

Goblal Configuration File

KERNEL Configuration

You can find the nodefony KERNEL configuration file
This config file do multiple tasks as :

  • parametrers http(s) servers start , listen domain and port, certificats
  • Domain Alias
  • AutoLoad differents framework bundles as security monitoring ...
  • Autoload services for render statics files (css, js , images ..)
  • locale (Lang) by default for all framework
Location : ./config/config.yml

#########################################################
#
#  nodefony framework
#
#       kernel config
#
#

system:
  domain                        : localhost             # nodefony can listen only one domain ( no vhost )  /    [::1] for ipv6 only
  domainalias:                                          # domainalias string only <>   example ".*\\.nodefony\\.com  ^nodefony\\.eu$ ^.*\\.nodefony\\.eu$"
    - "^127.0.0.1$"
  httpport                      : 5151
  httpsport                     : 5152
  statics                       : true
  security                      : true
  realtime                      : true
  monitoring                    : true
  documentation                 : true
  unittest                      : true
  locale                        : "en_en"

  servers:
    http                        : true
    https	                    : true
    ws			                : true
    wss			                : true
    certificats:
      key                       : "config/certificates/server/privkey.pem"
      cert                      : "config/certificates/server/fullchain.pem"
      ca                        : "config/certificates/ca/nodefony-root-ca.crt.pem"
      options:
        rejectunauthorized      : false

  bundles:
    demo                        : "src/bundles/demo-bundle"

  log:
    active                      : true

#
#       assets cdn
#
#       you set cdn with string
#       cdn :   cdn.nodefony.com
#       or
#       cdn:
#          global: cdn.nodefony.com
#       or
#       cdn:
#         stylesheet:
#           - cdn.nodefony.com
#         javascript:
#           - cdn.nodefony.com
#         image:
#           - cdn.nodefony.com
#           - cdn.nodefony.fr
#         font:
#           - cdn.nodefony.com
#
cdn                             : ~

#
# engine template
#
#       twig
#       https://github.com/justjohn/twig.js
#
templating                      : twig

#
# engine orm
#       sequelize
orm                             : sequelize

	  
Parameters Description Data Type Example / Default
name Name Framework String NODEFONY
version Version Framework String Alpha
system.domain

Domain or IP to listen servers HTTP / HTTPS / WEBSOCKET / WEBSOCKET SECURE nodefony can listen only one domain

String localhost or 192.168.0.230 or 127.0.0.1 nodefony.com
system.domainAlias Alias of domain String or array the separator is space for string type regexp only ".*\\.nodefony.com ^nodefony.eu$ ^.*\\.nodefony.eu$"
system.httpPort Port to listen servers HTTP / WEBSOCKET String 5151
system.httpsPort Port to listen servers HTTPS / WEBSOCKET SECURE String 5152
system.servers.http Start http server Boolean true
system.servers.https Start https server Boolean true
system.servers.ws Start websocket server Boolean true
system.servers.wss Start websocket secure server Boolean true
system.servers.certificats Manage certificats for https and websocket secure server tls.connect(options) Object
system.statics If active nodefony can Serve statics files : configurations of service in Application config file For developement use in production use varnish or similar reverse proxy caches in front to serve statics files Boolean true
system.security Auto registre Firewall Bundle Boolean true
system.realtime Auto registre realtime Bundle Boolean true
system.monitoring Auto registre monitoring Bundle (debugBar ... ) Boolean true
locale I18n lang Framework String en_en
CDN Manages CDN for all differents assets. Can be use in twig templates with built-in {{ CDN() }} Object
log.avtive Active syslog in kernel (show log in terminal ) Boolean true
templating Template Engine ( only twig for the moment) String twig
orm ORM Engine (only Sequelize for the moment) String sequelize

Certificates SSL HTTPS Directory ./config/certificates

ls -l ./config/certificates/

total 0
drwxr-xr-x  9 cci  staff  306  2 aoû 09:40 ca
drwxr-xr-x  8 cci  staff  272  2 aoû 09:40 ca_intermediate
drwxr-xr-x  4 cci  staff  136  2 aoû 09:40 client
drwxr-xr-x  6 cci  staff  204  2 aoû 09:40 server

config/certificates/
├── ca
│   ├── nodefony-root-ca.crt.pem
│   └── nodefony-root-ca.key.pem
├── ca_intermediate
│   └── certs
│       ├── ca-chain.cert.pem
│       ├── client.nodefony.cert.pem
│       ├── intermediate.cert.pem
│       └── server.nodefony.cert.pem
├── client
│   ├── chain.pem
│   └── pubkey.pem
└── server
    ├── cert.pem
    ├── chain.pem
    ├── fullchain.pem
    └── privkey.pem

You can manage your https certificates in this directory

Configuration PM2 File ./config/pm2.config.js

Configuration nodefony running mode : PM2 (Production process manager for Node.js )
This Configuration PM2 use by executable nodefony prod

const cpu = require('os').cpus().length;
let name = "myproject";
let script = process.argv[1] || "nodefony";
let logFile = path.resolve("tmp", "myproject.log");

/**
 * Application configuration section
 * http://pm2.keymetrics.io/docs/usage/application-declaration/
 */
module.exports = {
  apps: [{
    name: name,
    script: script,
    args: "pm2",
    //node_args           : "--expose-gc",
    watch: false,
    exec_mode: "cluster",
    instances: cpu,
    max_memory_restart: "1024M",
    autorestart: true,
    max_restarts: 10,
    //log_file            : logFile,
    out_file: logFile,
    error_file: logFile,
    merge_logs: true,
    env: {
      "NODE_ENV": "development",
      "MODE_START": "PM2",
      "NODEFONY_DEBUG": true
    },
    env_production: {
      "NODE_ENV": "production",
      "MODE_START": "PM2",
      "NODEFONY_DEBUG": false
    }
  }]
};
	            
Documentation pm2.keymetrics.io