diff --git a/Dockerfile b/Dockerfile index 79831cf06..65c2aa0b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,4 +33,4 @@ COPY \ README.md \ ./ -CMD ["pm2-docker", "./loopback/server/server.js"] +CMD ["pm2-runtime", "./back/process.yml"] diff --git a/Jenkinsfile b/Jenkinsfile index 81fb1c965..a462973ce 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,13 +6,15 @@ pipeline { disableConcurrentBuilds() } environment { - PROJECT_NAME = 'salix' - REGISTRY = 'registry.verdnatura.es' - DOCKER_HOST_1 = 'vch1.verdnatura.es' - DOCKER_HOST_2 = 'vch2.verdnatura.es' - PORT_MASTER = '5002' - PORT_TEST = '5001' - TAG = "${env.BRANCH_NAME}" + PROJECT_NAME = 'salix' + REGISTRY = 'registry.verdnatura.es' + DOCKER_HOST_1 = 'vch1.verdnatura.es' + DOCKER_HOST_2 = 'vch2.verdnatura.es' + PORT_MASTER_FRONT = '5002' + PORT_MASTER_BACK = '3001-3005' + PORT_TEST_FRONT = '5001' + PORT_TEST_BACK = '4001-4005' + TAG = "${env.BRANCH_NAME}" } stages { stage('Checkout') { @@ -31,10 +33,12 @@ pipeline { switch (env.BRANCH_NAME) { case 'master': - env.PORT = PORT_MASTER + env.PORT_FRONT = PORT_MASTER_FRONT + env.PORT_BACK = PORT_MASTER_BACK break case 'test': - env.PORT = PORT_TEST + env.PORT_FRONT = PORT_TEST_FRONT + env.PORT_BACK = PORT_TEST_BACK break } switch (env.BRANCH_NAME) { diff --git a/back/process.yml b/back/process.yml new file mode 100644 index 000000000..3e9f3ef19 --- /dev/null +++ b/back/process.yml @@ -0,0 +1,6 @@ +apps: + - script: ./loopback/server/server.js + name: salix-back + cron_restart: 0 */2 * * * + instances: 1 + max_restarts: 10 diff --git a/docker-compose.yml b/docker-compose.yml index 7fcf95a79..cd08ac0e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,15 @@ services: context: . dockerfile: front/Dockerfile ports: - - ${PORT}:80 + - ${PORT_FRONT}:80 links: - back back: image: registry.verdnatura.es/salix-back:${TAG} restart: unless-stopped build: . + ports: + - ${PORT_BACK}:3000 environment: - NODE_ENV volumes: diff --git a/front/nginx.conf b/front/nginx.conf index bbba60ab2..64f9436f3 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -1,16 +1,4 @@ -set_real_ip_from 0.0.0.0/0; -real_ip_header X-Forwarded-For; -log_format upstreamlog - '[$time_local] $remote_addr -> $proxy_host:$upstream_addr ' - '"$request" $status $body_bytes_sent ' - '"$http_referer" "$http_user_agent"'; -access_log /var/log/nginx/access.log upstreamlog; - -upstream back { - server back_1:3000; - server back_2:3000; -} server { listen 80 default_server; listen [::]:80 default_server; @@ -24,9 +12,6 @@ server { location @notfound { return 302 /; } - location ~ ^(/[a-zA-Z0-9_-]+)?/(?api(/.*)?)$ { - proxy_pass http://back/$path$is_args$args; - } location / { autoindex on; } diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index d03d52ae8..0191967b1 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -20,7 +20,7 @@ module.exports = function(Self) { this.beginTransaction = function(options, cb) { options = options || {}; if (!options.timeout) - options.timeout = 30000; + options.timeout = 120000; return orgBeginTransaction.call(this, options, cb); }; });