dwyl / learn-devops

🚧 Learn the craft of "DevOps" (Developer Operations) to Deploy your App and Monitor it so it stays "Up"!
GNU General Public License v2.0
419 stars 172 forks source link

error: failed to push some refs to 'dokku@...' #26

Closed nelsonic closed 6 years ago

nelsonic commented 6 years ago
-----> Build succeeded!
-----> Discovering process types
       Default types for  -> web
-----> Releasing hello (dokku/hello:latest)...
-----> Deploying hello (dokku/hello:latest)...
-----> Attempting to run scripts.dokku.predeploy from app.json (if defined)
-----> App Procfile file found (/home/dokku/hello/DOKKU_PROCFILE)
-----> DOKKU_SCALE file not found in app image. Generating one based on Procfile...
-----> New DOKKU_SCALE file generated
=====> web=1
-----> Attempting pre-flight checks
       For more efficient zero downtime deployments, create a file CHECKS.
       See http://dokku.viewdocs.io/dokku/deployment/zero-downtime-deploys/ for examples
       CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
-----> Default container check successful!
-----> Running post-deploy
-----> Creating new /home/dokku/hello/VHOST...
-----> Setting config vars
       DOKKU_PROXY_PORT:  80
-----> Setting config vars
       DOKKU_PROXY_PORT_MAP:  http:80:5000
-----> Configuring hello....(using built-in template)
-----> Configuring hello.ademo.app...(using built-in template)
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
       Reloading nginx
remote: Job for nginx.service invalid.
To 138.68.163.126:hello
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'dokku@138.68.163.126:hello'
nelsonic commented 6 years ago

the way I "fixed" this was by "killing" nginx with the command:

kill $(ps aux | grep '[n]ginx' | awk '{print $2}')

Not "pretty" but it worked.

Then I re-started nginx by simply running the nginx executable.

nelsonic commented 6 years ago

Turns out this only "works" once ... and does not "fix" anything. The next time attempting to git push dokku master the error will appear again.

nelsonic commented 6 years ago

The console shows this error but the app actually deployed successfully! https://hello-dokku.ademo.app image

I'm a little "concerned" that the "error" is a "false negative". But closing.

nelsonic commented 6 years ago

This is still an issue and I want to fix it because I don't want any errors/warnings anywhere! "address the problems when they are small." See: https://en.wikipedia.org/wiki/Broken_windows_theory

nelsonic commented 6 years ago

next line of enquiry: https://github.com/npm/npm/issues/3867 combined with using a "preinstall" script in package.json see: https://docs.npmjs.com/misc/scripts

nelsonic commented 6 years ago

a much "cleaner" way of doing this is:

pkill nginx

via: https://unix.stackexchange.com/questions/365740/centos-killall-command-to-kill-all-processes-with-names-matching-a-given-patt/365741

Then we need to run:

systemctl start nginx

That way we avoid deployment failure.

nelsonic commented 6 years ago

I managed to avoid the error (error: failed to push some refs) by shutting down Nginx before deploying the new app and restarting nginx https://github.com/nelsonic/hello-world-node-http-server/blob/5b6f2a29d8d4568cf7337a84ceecf666e50d353e/bin/deploy.sh#L35-L37 once the app has been successfully deployed: https://github.com/nelsonic/hello-world-node-http-server/blob/5b6f2a29d8d4568cf7337a84ceecf666e50d353e/bin/deploy.sh#L51-L53

This is not an ideal way of "solving" the issue as it means nginx will be "offline" while the app is being deployed ... So if someone is using a different app/version on the same server, their session will be interrupted ... This is only an issue for "full-refresh" Apps. We intend to build "offline first" apps so I'm considering this "solved" (for now)