Gathering detailed insights and metrics for @gapi/starter-basic-microservices
Gathering detailed insights and metrics for @gapi/starter-basic-microservices
Gathering detailed insights and metrics for @gapi/starter-basic-microservices
Gathering detailed insights and metrics for @gapi/starter-basic-microservices
npm install @gapi/starter-basic-microservices
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1git clone https://github.com/Stradivario/gapi-starter-microservices
1npm i -g @gapi/cli
1gapi new my-project --microservices
1npm start
This will run following commands "pm2 process.yml --only APP" (DEVELPOMENT) or "pm2-docker process.yml --only APP"(PRODUCTION inside docker) (check process.yml inside root repository)
1npm run start:prod
Following command will stop pm2 processes started
1npm run stop:prod
1gapi test
1gapi start
1gapi test --watch
1 if (process.env.BEFORE_HOOK) { 2 // do something here 3 }
1gapi test --before
1gapi app build
1gapi app start
1gapi app stop
1gapi workers start
1gapi workers stop
1apps: 2 - script : './src/main.ts' 3 name : 'APP' 4 exec_mode: 'cluster' 5 instances: 4 6
1upstream app_servers { 2 server 182.10.0.3:9000; # Main process 3 server 182.10.0.21:9000; # Worker 1 4 server 182.10.0.22:9000; # Worker 2 5 server 182.10.0.23:9000; # Worker 3 6 server 182.10.0.24:9000; # Worker 4 7 8 # Add more workers here 9 # server 182.10.0.25:9000; # Worker 5 10} 11 12server { 13 listen 80; 14 server_name api.yourdomain.com; 15 access_log api-yourdomain.access.log; 16 17 location / { 18 proxy_set_header Upgrade $http_upgrade; 19 proxy_set_header Connection "upgrade"; 20 client_max_body_size 50M; 21 proxy_set_header Host $http_host; 22 proxy_set_header X-Real-IP $remote_addr; 23 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 24 proxy_set_header X-Forwarded-Proto $scheme; 25 proxy_set_header X-Frame-Options SAMEORIGIN; 26 proxy_buffers 256 16k; 27 proxy_buffering off; 28 proxy_buffer_size 16k; 29 proxy_read_timeout 600s; 30 proxy_pass http://app_servers; 31 } 32 33 location /subscriptions { 34 # prevents 502 bad gateway error 35 proxy_buffers 8 32k; 36 proxy_buffer_size 64k; 37 38 # redirect all HTTP traffic to localhost:9000; 39 proxy_pass http://app_servers/subscriptions; 40 proxy_set_header X-Real-IP $remote_addr; 41 proxy_set_header Host $http_host; 42 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 43 #proxy_set_header X-NginX-Proxy true; 44 45 # enables WS support 46 proxy_http_version 1.1; 47 proxy_set_header Upgrade $http_upgrade; 48 proxy_set_header Connection "upgrade"; 49 proxy_buffering off; 50 proxy_read_timeout 999999999; 51 52 } 53 if ($scheme = http) { 54 return 301 https://$server_name$request_uri; 55 } 56 listen 443; 57 ssl on; 58 ssl_certificate /usr/share/certs/cert.pem; 59 ssl_certificate_key /usr/share/certs/cert.key; 60} 61 62
1config: 2# Application configuration 3 app: 4 local: 5 API_PORT: 9000 6 API_CERT: ./cert.key 7 NODE_ENV: development 8 AMQP_HOST: 182.10.0.5 9 AMQP_PORT: 5672 10 GRAPHIQL: true 11 GRAPHIQL_TOKEN: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImtyaXN0aXFuLnRhY2hldkBnbWFpbC5jb20iLCJpZCI6MSwic2NvcGUiOlsiQURNSU4iXSwiaWF0IjoxNTIwMjkxMzkyfQ.9hpIDPkSiGvjTmUEyg_R_izW-ra2RzzLbe3Uh3IFsZg 12 ENDPOINT_TESTING: http://localhost:9000/graphql 13 TOKEN_TESTING: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImtyaXN0aXFuLnRhY2hldkBnbWFpbC5jb20iLCJzY29wZSI6WyJBRE1JTiJdLCJpZCI6MSwiaWF0IjoxNTE2OTk2MzYxfQ.7ANr5VHrViD3NkCaDr0nSWYwk46UAEbOwB52pqye4AM 14 prod: 15 API_PORT: 9000 16 API_CERT: ./cert.key 17 NODE_ENV: production 18 AMQP_HOST: 182.10.0.5 19 AMQP_PORT: 5672 20# Testing configuration for local(dev) or worker(running tests as a separate worker with separate environment) 21 test: 22 local: extends app/local 23 worker: 24 API_PORT: 9000 25 API_CERT: ./cert.key 26 NODE_ENV: production 27 AMQP_HOST: 182.10.0.5 28 AMQP_PORT: 5672 29 ENDPOINT_TESTING: http://182.10.0.101:9000/graphql 30 TOKEN_TESTING: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImtyaXN0aXFuLnRhY2hldkBnbWFpbC5jb20iLCJzY29wZSI6WyJBRE1JTiJdLCJpZCI6MSwiaWF0IjoxNTE2OTk2MzYxfQ.7ANr5VHrViD3NkCaDr0nSWYwk46UAEbOwB52pqye4AM 31 32 schema: 33 introspectionEndpoint: http://localhost:9000/graphql 34 introspectionOutputFolder: ./src/app/core/api-introspection 35 36commands: 37 38 testing: 39 stop: 40 - docker rm -f gapi-api-prod-worker-tests-executor 41 - docker rm -f gapi-api-prod-worker-tests-provider 42 start: 43 - gapi testing start-provider 44 - sleep 10 45 - gapi testing start-executor 46 - echo Cleaning... 47 - gapi testing stop 48 start-provider: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.101 --name gapi-api-prod-worker-tests-provider gapi/api/prod 49 start-executor: 50 - docker run -d --network=gapiapiprod_gapi --ip=182.10.0.100 --name gapi-api-prod-worker-tests-executor gapi/api/prod 51 - docker exec gapi-api-prod-worker-tests-provider npm -v 52 - gapi test --worker --before 53 54 workers: 55 start: 56 - gapi workers start-1 57 - gapi workers start-2 58 - gapi workers start-3 59 - gapi workers start-4 60 stop: 61 - docker rm -f gapi-api-prod-worker-1 62 - docker rm -f gapi-api-prod-worker-2 63 - docker rm -f gapi-api-prod-worker-3 64 - docker rm -f gapi-api-prod-worker-4 65 start-1: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.21 --name gapi-api-prod-worker-1 gapi/api/prod 66 start-2: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.22 --name gapi-api-prod-worker-2 gapi/api/prod 67 start-3: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.23 --name gapi-api-prod-worker-3 gapi/api/prod 68 start-4: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.24 --name gapi-api-prod-worker-4 gapi/api/prod 69 example-worker-with-port: docker run -d --network=gapiapiprod_gapi --ip=182.10.0.25 --name gapi-api-prod-worker-5 -p 9001:9000 gapi/api/prod 70 71 app: 72 start: 73 - docker-compose -p gapi-api-prod up --force-recreate -d 74 - gapi rabbitmq enable-dashboard 75 stop: 76 - gapi nginx stop 77 - gapi api stop 78 - gapi rabbitmq stop 79 - gapi postgres stop 80 build: docker build -t gapi/api/prod . 81 82 api: 83 stop: docker rm -f gapi-api-prod 84 85 nginx: 86 stop: docker rm -f gapi-api-nginx 87 88 postgres: 89 stop: docker rm -f gapi-api-postgres 90 91 rabbitmq: 92 stop: docker rm -f gapi-api-rabbitmq 93 restart: docker restart gapi-api-rabbitmq 94 enable-dashboard: docker exec gapi-api-rabbitmq rabbitmq-plugins enable rabbitmq_management 95 96# You can define your custom commands for example 97# commands: 98# your-cli: 99# my-command: 'npm -v' 100# This command can be executed as "gapi your-cli my-command"
1start-5: 'docker run -d --network=gapiapiprod_gapi --ip=182.10.0.25 --name gapi-api-prod-worker-5 -p 9005:9000 gapi/api/prod'
1start: 'gapi workers start-1 && gapi workers start-2 && gapi workers start-3 && gapi workers start-4 & gapi workers start-5'
1start-5: 'docker run -d --network=gapiapiprod_gapi --ip=182.10.0.25 --name gapi-api-prod-worker-5 gapi/api/prod'
1 nginx: 2 image: sameersbn/nginx:1.10.1-5 3 ports: 4 - "81:80" 5 - "443:443"
1version: '2' 2services: 3 4 nginx: 5 image: sameersbn/nginx:1.10.1-5 6 ports: 7 - "80:80" 8 - "443:443" 9 volumes: 10 - ./nginx/config:/etc/nginx 11 - ./nginx/html:/usr/share/nginx/html/ 12 - ./nginx/certs:/usr/share/certs 13 restart: always 14 container_name: gapi-api-nginx 15 networks: 16 gapi: 17 ipv4_address: 182.10.0.2 18 19 api: 20 image: gapi/api/prod:latest 21 ports: 22 - "9000" 23 restart: always 24 mem_limit: 1000000000 25 cpu_shares: 73 26 container_name: gapi-api-prod 27 depends_on: 28 - nginx 29 - rabbitMq 30 networks: 31 gapi: 32 ipv4_address: 182.10.0.3 33 34 rabbitMq: 35 image: rabbitmq:3.7.2 36 ports: 37 - "15672:15672" 38 - "5672:5672" 39 - "5671:5671" 40 - "4369:4369" 41 restart: always 42 container_name: gapi-api-rabbitmq 43 networks: 44 gapi: 45 ipv4_address: 182.10.0.5 46 47networks: 48 gapi: 49 driver: bridge 50 ipam: 51 config: 52 - subnet: 182.10.0.0/16 53 gateway: 182.10.0.1 54
TODO: Better documentation...
Enjoy ! :)
No vulnerabilities found.
No security vulnerabilities found.