Giter VIP home page Giter VIP logo

Comments (44)

nickjj avatar nickjj commented on June 11, 2024

Hard to say without more details but a 404 makes me think maybe you need to update your SERVER_NAME setting to match your domain name or IP.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

No registered domain yet, still using server's IP.
In config.py currently SERVER_NAME = '46.xxx.xx.xxx:8000'. Correct no?

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Yes, that should work assuming it's the correct IP of your server.

At the moment there's too many unknowns. How are you deploying it? Are you one my students in the Docker for DevOps course (it goes into great detail on deploying a Flask app to production).

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

yes yes I deploy through dockerfordevops by running deploy.sh I have the Udemy
everythng works postgres nginx redis, except for the cat watch with the 404
so issue with cat watch so I post here

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

docker ps output maybe useful:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e69ef949457 nginx "/docker-entrypoint n" About an hour ago Up About an hour 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp nginx
2131badaa7d5 catwatch "/bin/sh -c 'gunicorn" About an hour ago Up About an hour 0.0.0.0:8000->8000/tcp catwatch
b6de2bfc7ef8 postgres:9.4.5 "/docker-entrypoint.s" About an hour ago Up About an hour 0.0.0.0:5432->5432/tcp postgres
41e2af60ce0e redis:2.8.22 "/entrypoint.sh redis" About an hour ago Up About an hour 0.0.0.0:6379->6379/tcp redis

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Do you have the 46.X IP address set in nginx?

Also if you're using nginx, then you will need to remove the :8000 in SERVER_NAME and just access your IP address directly with no port.

After making 1 or both of those changes make sure you rebuild/deploy nginx, or copy over the new settings config, etc..

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

I've deleted your comment that contained the source code to the course's material, since it's not open source.

I did download it and will take a look at it soon.

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Have you looked at the nginx config on your server? You can docker exec into a running instance of nginx and then run bash so you can snoop around the config file.

I'd be curious to see if they are what you think they should be.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

sorry ofcourse did not think
ok i will check too

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Any luck?

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

starting on fresh server to do everything again now

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

unfortunately not work
I try mobydock again and it work! but cat watch always fail
I can't know why

from build-a-saas-app-with-flask.

elie-h avatar elie-h commented on June 11, 2024

I never managed to combine both courses together either.
However I did see the same issue you're facing treldor. I remember making progress by redoing the SSL certificates as nick suggested in an email. So maybe try that?

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Yep, you'll need to make sure you copied over both the SSL certificates as well as your instance/settings.py file.

The easiest way to determine that's wrong would be to look at the docker logs for both nginx and catwatch on your server.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

SSL exists i make again.
on fresh server from systemd now i always getting: Failed to start Run catwatch.
so if cat watch does not run then nginx does not run.

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Does it say why it failed to start?

Try doing sudo journalctl -u catwatch (or whatever your systemd unit file is named). If that doesn't give you anything useful then do a docker ps -a and then run a docker logs abc123 where abc123 is the failed container ID for catwatch.

You can repeat the same steps for nginx too at some point.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

OK! maybe I find error!!!
I do like you said: docker exec bash
then check /etc/nginx/conf.d/default.conf
server value still = www.production.com not the droplet IP

Like this:

server {
listen 80;
listen 443;
server_name www.productionexample.com;
return 301 https://productionexample.com$request_uri;
}

but in the nginx folder I using locally and git pushing it is the correct IP
I try fixing manually but when i restart docker it reset values www.productionexample.com

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

What is the hostname on your server? You can run hostname on your server. It will only replace the correct server_name if the hostname doesn't match what you define in the docker-entrypoint file for nginx.

Also in your zip file you have a semi-colon after the domain name, that should be removed.

This strategy was explained in the Docker course. It allows you to use the same nginx configs for both staging and production. I would double check the nginx.conf from the Docker course as well as the entrypoint file to see how it's done.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

hostname: treldor_moby, different from STAGING_HOSTNAME.
I make DOMAIN_NAME= "4x.xxx.xx.xxx" correct IP
push new code & restart docker
but still 404 in browser :/

From docker logs:
Nginx logs sending http request:

 - - [16/Mar/2016:22:48:51 +0000] "GET / HTTP/1.1" 404 136 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"
 - - [16/Mar/2016:22:48:52 +0000] "GET / HTTP/1.1" 404 136 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"
- - [16/Mar/2016:22:48:53 +0000] "GET / HTTP/1.1" 404 136 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"

Catwatch logs is still blank:

[2016-03-16 22:45:01 +0000] [7] [INFO] Starting gunicorn 19.3.0
[2016-03-16 22:45:01 +0000] [7] [INFO] Listening at: http://0.0.0.0:8000 (7)
[2016-03-16 22:45:01 +0000] [7] [INFO] Using worker: sync
[2016-03-16 22:45:01 +0000] [12] [INFO] Booting worker with pid: 12

Initializing Flask-DebugToolbar log handler

INFO in register [/catwatch/catwatch/register.py:170]:

GET "/" in 6ms for xxx.xxx.x.x

GET "/" in 6ms for xxx.xxx.x.x

INFO in register [/catwatch/catwatch/register.py:170]:

GET "/" in 0ms for xxx.xxx.x.x

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

did you put STAGING_HOSTNAME="treldor_moby" in the entrypoint file?

You'd also need to add -> commit -> push nginx.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

no i have STAGING_HOSTNAME="stagingserver"
and DOMAIN_NAME="46.xx.xx.xx" < droplet ip

correct? because then if statement will replace staging IP with domain IP inside "/etc/nginx/conf.d/default.conf"

yes I git add and commit and push correctly

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

STAGING_HOSTNAME needs to be the hostname of your server. I recommend reviewing how the staging server is set up and replicate that exactly on your end for catwatch.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

but this is for production droplet in digital ocean!
following lecture 80 dockerfordevops

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

The only possible way for it to be using productionexample.com as the server_name is because you haven't commit/pushed nginx to the DO server.

The only place that's being set is in the docker-entrypoint file of nginx.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

Ok now I do:

rm -rf .git
git init
git add -A
git commit -am "Initial Commit"
git remote add production ssh://[email protected]:/var/git/nginx.git
git push production master

maybe before I skip step.
now "/etc/nginx/conf.d/default.conf" is correct in docker image:

upstream catwatch {
server catwatch:8000;
}

AND

server_name 46.xxx.xx.xxx; (correct IP)

if default.conf is open source i can post file here if easier to debug

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

still 404 in browser!

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

If what you say about the default.conf file is true (it's not open source) then it should be good.

Now, are you sure SERVER_NAME is set to the IP address without the port 8000? Check the config on your DO server.

Have you re-looked at any of the Docker logs for both containers since pushing the correct version?

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

yes I go on droplet:
docker exec nginx bash
cat /etc/nginx/conf.d/default.conf

SERVER catwatch:8000
and
SERVER_NAME 46.xx.xx.xx; (droplet ip with no port)

from build-a-saas-app-with-flask.

elie-h avatar elie-h commented on June 11, 2024

Could you please do:
docker ps
docker images

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

ok:

IMAGES THEN PS:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
nginx               latest              482f5bdcbf59        10 minutes ago      190.5 MB
catwatch            latest              96153d66f027        About an hour ago   693.9 MB
nginx               1.9                 6f62f48c4e55        7 days ago          190.5 MB
postgres            9.4.5               de35bfc3a186        7 weeks ago         263.1 MB
python              2.7.10-slim         0d91c552e0d8        3 months ago        204.9 MB
redis               2.8.22              579cf374438d        5 months ago        109 MB


CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES
236ff10bfe17        nginx               "/docker-entrypoint n"   10 minutes ago      Up 10 minutes       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   nginx
82711661058e        catwatch            "/bin/sh -c 'gunicorn"   45 minutes ago      Up 45 minutes       0.0.0.0:8000->8000/tcp                     cat watch
fe37bd5d6092        postgres:9.4.5      "/docker-entrypoint.s"   45 minutes ago      Up 45 minutes       0.0.0.0:5432->5432/tcp                     postgres
9ed0064eeb80        redis:2.8.22        "/entrypoint.sh redis"   45 minutes ago      Up 45 minutes       0.0.0.0:6379->6379/tcp                     redis

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

That's a different server name. I mean the one in instance/settings.py for catwatch. It needs to be 46.xx.xx.xx and this file needs to be copied/mounted to your catwatch container in the same way moby dock was in the Docker course.

This one:
https://github.com/nickjj/build-a-saas-app-with-flask/blob/master/instance/settings.py.production_example#L3

from build-a-saas-app-with-flask.

elie-h avatar elie-h commented on June 11, 2024

Nick, shouldn't the other docker images be running too?
Faye and cadvisor

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Yep, Faye should be at least. cadvisor should technically be running but it's very possible he just removed it since it's not essential.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

i have settings.py not settings.py.production? in the folder of the production or the local?
it is for sure committed to the code? or should it be manual?

from build-a-saas-app-with-flask.

elie-h avatar elie-h commented on June 11, 2024

SSH into your droplet then:

sudo nano /home/YOURUSERNAME/instance/settings.py
add the line: SERVER_NAME = 'DROPLETS_IP'
sudo systemctl restart docker

This isn't the way it's done in the course.
But just to confirm if it is causing the 404 do it manually like above.

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

It should be settings.py. It has the .production in the git repo because settings.py is added to gitignore, since this file would contain sensitive information.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

YES! IT WORK!!!! THNX SO MUCH TWO OF YOU!!!

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Glad you got it working.

It's similar to the course, the only difference is the SERVER_NAME is set to a domain name rather than the IP address of the droplet. Same concept, different values.

Thanks for helping out @eliehamouche.

from build-a-saas-app-with-flask.

elie-h avatar elie-h commented on June 11, 2024

Great!
Thank Nick!

Add Faye to the docker images in the deploy script in: DOCKER_PULL_IMAGES
If I remember correctly that's the only addition you have to make to deploy.sh to accommodate for Catwatch.

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Right, since the Docker course's example app didn't have Faye.

Also to expand on your previous comment, you only need to restart the catwatch container after editing that instance/settings.py file. You don't need to restart docker fully (this will restart everything).

You can simply run: docker stop catwatch , and systemd will automatically restart it with the new changes.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

good very good!

any .service file for Faye?

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

I'll leave that as a homework assignment for you. The service file would be very similar to the other service files. Just look at the postgres or redis service file and modify it.

It's part of the paid content for the course that goes over this open source project.

However, I don't recommend buying it just yet because I'm in the process of making massive changes in the near future.

You can read about them @ http://nickjanetakis.com/blog/build-a-saas-app-with-flask-is-getting-a-complete-make-over-soon.

from build-a-saas-app-with-flask.

treldor avatar treldor commented on June 11, 2024

ok i will do it! thank you. very good learning experience.
i close finally! thank you for patience

from build-a-saas-app-with-flask.

nickjj avatar nickjj commented on June 11, 2024

Thanks, and no problem.

You'll also want to create a service file for Celery too. Just use the catwatch one as a reference, it's nearly the same.

from build-a-saas-app-with-flask.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.