Nginx 502 bad gateway google cloud run the site takes approximately 50 minutes then starts working

The docker container works just fine when tested locally, upon deployment on cloud run I get 502 bad gateway. It takes approximately 50 – 60 min then for no reason starts working….causing a site down time. Have been onto this for approximately a week now no success on figuring out why this is happenning.

History:

I was deploying a Vuejs build static build before everything was working fine… i recently re-wrote my front end to Nuxtjs that’s when the deployment problems started.

How am testing dockerfile build:

As recommended by google am using : PORT=8080 && docker run -p 9090:${PORT} -e PORT=${PORT} myImage:latest check here

Dockfile:

# Alpine Deployment Server
FROM nginx:stable-alpine as alpine-server
# Dependencies for backend
RUN apk update && apk add --no-cache python3 && 
    python3 -m ensurepip && 
    rm -r /usr/lib/python*/ensurepip && 
    pip3 install --upgrade pip setuptools wheel && 
    if ( ! -e /usr/bin/pip ); then ln -s pip3 /usr/bin/pip ; fi && 
    if (( ! -e /usr/bin/python )); then ln -sf /usr/bin/python3 /usr/bin/python; fi && 
    rm -r /root/.cache
RUN apk add --no-cache gcc libxml2-dev libxslt-dev libressl-dev libffi-dev musl-dev postgresql-dev openssl-dev python3-dev cargo chromium-chromedriver chromium coreutils
RUN pip install cryptography==3.1.1 cffi scrapy selenium flask flask-cors flask-caching fuzzywuzzy 
    python-levenshtein requests aiohttp gunicorn scrapy-useragents scrapyrt
ENV DISPLAY=:99
ENV PORT=8080
WORKDIR /app
# Building frontend
RUN apk add --update nodejs nodejs-npm
RUN npm install pm2@latest -g
COPY ./client .
RUN npm ci && npm run build
COPY ./api .
COPY ./server .
COPY ./server/Extras .
COPY .htpasswd /etc/nginx/.htpasswd
RUN mkdir -p /data/nginx/cache
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
CMD pm2 start > pm2.log && 
    gunicorn -b 0.0.0.0:5000 --workers 1 --threads 8 --timeout 0 api:app --daemon && 
    gunicorn -b 0.0.0.0:5001 --workers 1 --threads 1 --timeout 0 extras:app --daemon && 
    nohup sh -c "scrapyrt -p 7000 -i 0.0.0.0" > /dev/null 2>&1 & 
    nginx -g 'daemon off;'

NB: Nuxt is also configured to start at 0.0.0.0:3000 am using pm2 to start Nuxt

NGINX CONFIG

proxy_cache_path  /data/nginx/cache  levels=1:2    keys_zone=STATIC:10m
    inactive=24h  max_size=3g;
# Expires map
map $sent_http_content_type $expires {
    default off;
    text/html epoch;
    "text/html; charset=utf-8"  epoch;
    font/woff2 max;
    font/woff max;
    text/css max;
    application/javascript max;
    ~image/ max;
}
server {
  listen 8080;
  server_name chekiprice.co.ke;

  charset utf-8;

   location / {
    expires $expires;

    proxy_redirect                      off;
    proxy_set_header Host               $host;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_http_version                  1.1;
    proxy_set_header                    Upgrade $http_upgrade;
    proxy_set_header                    Connection "upgrade";
    proxy_set_header X-Forwarded-Host   $server_name;
    proxy_buffering                     on;
    proxy_read_timeout                  1m;
    proxy_connect_timeout               1m;
    proxy_pass                          http://127.0.0.1:3000;
    proxy_cache                         STATIC;
    proxy_cache_valid                   200  1d;
    proxy_cache_use_stale               error timeout invalid_header updating
                                        http_500 http_502 http_503 http_504; 
  }

  location ~^/api/v1/(.+)/search/(.+)$ {
    set $allowspace2 $2;
    proxy_pass          http://127.0.0.1:5000/api/v1/$1/search/$allowspace2;
    proxy_http_version  1.1;
    proxy_redirect      ~^/api/v1/(.+)/search/(.+)$ http://127.0.0.1:5000/api/v1/$1/search/$allowspace2;
    proxy_set_header    Upgrade $http_upgrade;
    proxy_set_header    Connection "upgrade";
    proxy_set_header    Host $host;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Host $server_name;
    proxy_buffering     on;
    proxy_cache         STATIC;
    proxy_cache_valid   200  1d;
    proxy_cache_use_stale  error timeout invalid_header updating
                           http_500 http_502 http_503 http_504;
    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;
  }

  location ~^/api/v1/(.+)/view/(.+)$ {
    set $allowspace2 $2;
    proxy_pass          http://127.0.0.1:5000/api/v1/$1/view/$allowspace2;
    proxy_http_version  1.1;
    proxy_redirect      ~^/api/v1/(.+)/view/(.+)$ http://127.0.0.1:5000/api/v1/$1/view/$allowspace2;
    proxy_set_header    Upgrade $http_upgrade;
    proxy_set_header    Connection "upgrade";
    proxy_set_header    Host $host;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Host $server_name;
    proxy_buffering     on;
    proxy_cache         STATIC;
    proxy_cache_valid   200  1d;
    proxy_cache_use_stale  error timeout invalid_header updating
                           http_500 http_502 http_503 http_504;
    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;
  }
  location ~^/extras/v1/(.+)/(.+)$ {
    set $allowspace2 $2;
    proxy_pass          http://127.0.0.1:5001/extras/v1/$1/$allowspace2;
    proxy_http_version  1.1;
    proxy_redirect      ~^/extras/v1/(.+)/(.+)$ http://127.0.0.1:5001/extras/v1/$1/$allowspace2;
    proxy_set_header    Upgrade $http_upgrade;
    proxy_set_header    Connection "upgrade";
    proxy_set_header    Host $host;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Host $server_name;
    proxy_buffering     on;
    proxy_cache         STATIC;
    proxy_cache_valid   200  1d;
    proxy_cache_use_stale  error timeout invalid_header updating
                           http_500 http_502 http_503 http_504;
  }
    location /crawl {
    proxy_pass          http://127.0.0.1:7000/crawl.json;
    proxy_http_version  1.1;
    proxy_redirect      default;
    proxy_set_header    Upgrade $http_upgrade;
    proxy_set_header    Connection "upgrade";
    proxy_set_header    Host $host;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Host $server_name;
  }
    gzip on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_comp_level 6;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_vary on;
}

What ERROR is logged cloud run when trying to navigate to url during 502 bad Gateway ?

*13 connect() failed (111: Connection refused) while connecting to upstream,....

What bums me out is why ??

  1. Why the upstream are offline, all services are started first then
    NGINX is started.

  2. Why does it take long and eventually start.

  3. Why it works just locally on deployment to cloud run its just hocus-pocus.

How do I resolve this ??

systemd – Mount ZFS pool before snapd starts

I have a zpool that has a mountpoint at /var. When I start my server up, the snapd service always throws a bunch of errors and fails to start because it attempts to mount a bunch of things from /var to /snap but it attempts the mounts before the zpool has been mounted so there’s nothing in /var yet.

How can I get snapd to attempt these mounts after the zpool has been mounted?

json column formatting, button that starts flow – can I prevent multiple clicks?

I have a button that starts Approval flow, with ‘visibility’ attribute that hides it if ‘Status’ column has value. But users make double-click and open Flow panel twice or more times, so my flow runs multiple times.
Can I add some logic to this json button that allows only one click and prevents users to start flow multiple times, until they refresh page?

Here is json code:
Flow guid is stored in ‘actionParams’ key. It shows button only if ‘RequestStatus’ is Empty or Rejected (‘visibility’ key), but Status is changed later, after flow started, and does not protect from multiple clicks in the beginning..

For example in jQuery it was able with e.preventDefault(); or something, but don’t know how to do same with json column formatting..

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Start Approval process",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{"id": "********-****-4519-a15f-f1710899a003"}"
  },
  "style": {
    "background-color": "#0078d4",
    "color": "white",
    "max-width": "95px",
    "font-size": ".9em",
    "cursor": "pointer",
    "visibility": "=if(($RequestStatus)=='' || ($RequestStatus)=='Rejected' ,'visible','hidden')"
  }
}

❕NEWS – Famous Names Starts Bitcoin (BTC) Movement | Proxies-free

Today, SpaceX CEO Elon Musk added the hashtag #Bitcoin to his Twitter bio. After that, many names started adding #Bitcoin tags to their profile.
Reddit CEO Alexis Ohanian, founder of SkyBridge and world-renowned hedge fund manager Anthony Scaramucci, famous YouTuber Mr. Beast, Jimmy Donaldson also added a #Bitcoin hashtag. Twitter CEO Jack Dorsey also has the hashtag #Bitcoin in his biography.
What do you think about these interesting developments?

HOLIDAY SALE UPTO 70% OFF, Hosting plan starts from $0.30/M.

Happy Holidays! On the occasion of Christmas 2020, Year End and New Year, Raisinghost promotes its shared, reseller and WordPress hosting plans heavily.
Now you get upto 70% off on Raisinghost’s hosting plans with many amazing features like free website migration, free domain registration, unlimited space
and bandwidth etc, so act fast to grab these amazing offers.

Get advantage of these deals by using below promo codes at the time of checkout:

SAVEXMAS70 : Save flat 70% with all our shared, reseller hosting plans with annual billing cycle
SAVEXMAS50 : Save 50% for lifetime with all our shared, reseller hosting plans with annual billing cycle

Key Features included with all our shared, reseller, WordPress hosting plans :

– Easy and friendly control panel named cPanel
– 30 Day Money Back Guarantee
– 24/7/365 Technical Support
– 99.9% Uptime Guarantee
– 20x Times Faster Solid-State Drive Storage
– MariaDB (MySQL)
– Multiple PHP Versions (5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4)
– Daily Incremental Backups
– Softaculous Auto Installer
– FREE Website Builder (SitePad)
– FREE Unlimited SSL Certificates (Let’s Encrypt)
– Free Auto SSL
– FREE cPanel/WHM Migration
– Email routing through mail channels
– On Demand SSH Access
and much more!

*Get Deal : https://www.raisinghost.com/

Thank you.

*Hostpoco.com – Linux cPanel Reseller – Starts from $3 – Free SSL – FREE Migration. | Proxies-free

Hostpoco provides affordable and high-performance web hosting to our customers around the world. We have Linux Reseller Hosting, cPanel Hosting, shared hosting, Plesk Hosting, VPS Hosting, Dedicated Hosting plans from small to large to fit your requirements. All our services are offered by fast/instant setup, 24/7 dedicated support, 99.9% uptime guarantee, 30 days complete money-back guarantee & more features! Our goal is to provide outstanding services for the best possible price. To achieve these goals we are constantly innovating and upgrading our services at no additional cost to our customers.

Our plans are unique and have reasonable cheaper prices compare to every other hosting provider which only looks for income other than the relations but we value clients and looking for long-term clients only. Hurry up Now !!!

Features :

=================
– Instant Activation
– Free Setup
– No Hidden Charges
– Alerts and Notifications
– cPanel/whm control panel
– Softacolous Library
– Unlimited Bandwidth
– Unlimited Web Space
– Unlimited FTP Accounts
– Max Emails Per Hour
– Hassle-Free Services
– 24×7 Hosting Chat Support
– Money-Back Guarantee
=================

***Reseller Plan***
– Reseller Startup: $3 /Monthly
– Reseller Pro: $6 /Monthly
– Reseller Premium: $9 /Monthly
– Reseller Elite: $12 /Monthly

Order Now:https://hostpoco.com/cheap-linux-reseller-hosting.php

Hostpoco.com: cheap #host $1, hosting #offers, #web hosting offers, reseller #hosting offers, #instantcpanelhosting, #cheap hosting, hosting, cPanel host, WordPress host, cheap web host, budget #wordpress hosting, unlimited cPanel hosting, unlimited DB hosting, unlimited MySQL, unlimited databases, web hosting, hosting, web hosting, #linux shared hosting, half a dollar hosting, one dollar hosting, $1 hosting, $1 web hosting, $#1 unlimited hosting, #reliable web hosting, affordable web hosting, latest PHP hosting, free SSL hosting, money back hosting, cheap dedicated servers, low-cost #dedicated servers, priority hosting support, 24×7 support, best support hosting, dollar1host, dollar 1 host, dollar host, 1 dollar host, #1 dollar hosting, 1 #dollar web, web hosting $1, cheap hosting solutions, cheap VPS hosting, cheap SSL cert, #free domain hosting.

https://hostpoco.com/

If you have any questions, please do not hesitate to contact us.
Sales@hostpoco.com

Thank you.

*Hostpoco.com – Linux cPanel Reseller – Starts from $3 – Free SSL

Hostpoco provides affordable and high-performance web hosting to our customers around the world. We have Linux Reseller Hosting, cPanel Hosting, shared hosting, Plesk Hosting, VPS Hosting, Dedicated Hosting plans from small to large to fit your requirements. All our services are offered by fast/instant setup, 24/7 dedicated support, 99.9% uptime guarantee, 30 days complete money-back guarantee & more features! Our goal is to provide outstanding services for the best possible price. To achieve these goals we are constantly innovating and upgrading our services at no additional cost to our customers.

Our plans are unique and have reasonable cheaper prices compare to every other hosting provider which only looks for income other than the relations but we value clients and looking for long-term clients only. Hurry up Now !!!

Features :

=================
– Instant Activation
– Free Setup
– No Hidden Charges
– Alerts and Notifications
– cPanel/whm control panel
– Softacolous Library
– Unlimited Bandwidth
– Unlimited Web Space
– Unlimited FTP Accounts
– Max Emails Per Hour
– Hassle-Free Services
– 24×7 Hosting Chat Support
– Money-Back Guarantee
=================

***Reseller Plan***
– Reseller Startup: $3 /Monthly
– Reseller Pro: $6 /Monthly
– Reseller Premium: $9 /Monthly
– Reseller Elite: $12 /Monthly

Order Now:https://hostpoco.com/cheap-linux-reseller-hosting.php

Hostpoco.com: cheap #host $1, hosting #offers, #web hosting offers, reseller #hosting offers, #instantcpanelhosting, #cheap hosting, hosting, cPanel host, WordPress host, cheap web host, budget #wordpress hosting, unlimited cPanel hosting, unlimited DB hosting, unlimited MySQL, unlimited databases, web hosting, hosting, web hosting, #linux shared hosting, half a dollar hosting, one dollar hosting, $1 hosting, $1 web hosting, $#1 unlimited hosting, #reliable web hosting, affordable web hosting, latest PHP hosting, free SSL hosting, money back hosting, cheap dedicated servers, low-cost #dedicated servers, priority hosting support, 24×7 support, best support hosting, dollar1host, dollar 1 host, dollar host, 1 dollar host, #1 dollar hosting, 1 #dollar web, web hosting $1, cheap hosting solutions, cheap VPS hosting, cheap SSL cert, #free domain hosting.

https://hostpoco.com/

If you have any questions, please do not hesitate to contact us.
[email protected]

Thank you.