Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ben Friedland
    @BFriedland
    Wait, those errors are in the conditional on wait_for_running, which I never tested.
    So I didn't actually run through that part of the code -- if I run 'fab provision_instance' it'll spin up a server I can see in the AWS console and when using both 'fab select_instance' and 'fab list_aws_instances:verbose=1'
    Ben Friedland
    @BFriedland
    Figured out that the mystery 'i' variable can be changed to each_instance in my version of the tutorial assignment and it will work as intended. It seems that the syntax 'some_list.index(some_object_in_the_list)' will return the index of that object, which pop() will then work with. It is incorrect in the tutorial, but that's all that would need to be changed...

    And, as you said, the pop() part also doesn't work.
    for item in list:
    if item > 2:
    list.pop(list.index(item))

    will, as you said, fail to handle indices correctly after the first item has been removed.

    Fortunately we only need to put up one instance at a time, so we don't have to spend a long time fixing that part of the tutorial, but I wouldn't publish the fabfile with that part in it as accessible code.
    Charlie
    @charlieRode
    Yeah i rewrote the code; i haven't tested it yet but its as it makes sense to me.
    im coming in now. Had a late night but im omw
    Charlie
    @charlieRode
    Sorry, I've changed my mind. I'm going to work from home today. How are you guys coming along on deployment?
    Charles Gust
    @CharlesGust
    We are close. I'm having authentication and key pair problems, but we have just the pips and gunicorn to go, I think
    Ben Friedland
    @BFriedland
    We got the server working on AWS, but we had to use Nginx and Gunicorn simultaneously.
    The fabfile is still under construction.
    Ben Friedland
    @BFriedland
    Didn't get any real progress done since 6pm, unfortunately. "Fatal error: run() received nonzero return code -1 while executing!" while trying to have it pip install -r requirements.txt is the current holdup. Will have to look at it again tomorrow.
    Charlie
    @charlieRode
    I haven't made much progress today, really. Did you get the fabfile done?
    Charles Gust
    @CharlesGust
    Hi Charlie. We checked in what we had to the 'deployment1' branch. I think the fabfile was about 80% done, except none of the database setup was in there, and obviously you need more code to handle the S3/picture server stuff. Just to let you know, we had a cryptic error message (error502) that kept coming up running gunicorn. I had set up a CNAME of imagrapp.charlesgust.me but guess what? CNAME's can't have underscores. So, instead of deploying to a subdomain at charlesgust.me, we had to keep it at EC2<crazynumber>.amazonaws.com. Well, the security token that I thought was ONLY going to be used for POST also gives you 502 errors with GET. Who knew! We changed the token to '*", and were able to see imagr_app running on EC2 for the first time. It was a manual deployment; lots of typing at the SSH terminal, but it helped us develop the fabfile. Everything along the way was a gotcha. You have to run "update" and "upgrade" on your AMI (if you are using one from free tier that's crusty old like June 2014). You have to use something like nginx to proxy serve up the webpages (at least we couldnt get gunicorn to work by itself - but that was before we found the ALLOWED_HOSTS bug I just alluded to.). So, I think we are close, but I've felt we've been close for two days.
    Charlie
    @charlieRode
    God, what a mess. Okay, thanks Charles. Are you guys still at it?
    Ben Friedland
    @BFriedland
    I decided to read up a bit about gunicorn today. One of the things I found is that gunicorn's default configuration requires a proxy in front of it, which is why we seem to need Nginx.
    It has something to do with reducing vulnerabilities, I think. There was an explanation about it in the gunicorn docs somewhere (I cloned it down and grepped a few things).
    Charlie
    @charlieRode
    Are you guys going to be in tomorrow? I'm thinking ill try to get there early and stay all day
    Ben Friedland
    @BFriedland
    I'll probably be in tomorrow but I'm not sure. I've been working on building the fab file but I don't really know if I have anything to show for it yet, tiny steps take forever to debug since most of them have to do with updating a machine we're getting from Amazon (the AMI) and we have no idea what it's missing until it throws an error.
    For example, 'sudo pip install -r requirements.txt' was a weird one, because I was getting IncompleteRead for a while and it seemed I'd need to reinstall it. I ended up finding https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1306991/comments/24
    Ben Friedland
    @BFriedland
    which suggested I should uninstall pip and get it from another source -- that all works on my machines if I remove the '3' part of 'python3'.
    So I commented 'apt-get -y install python-pip' in the apt-gets and inserted the two lines from that bug report comment I linked inside _install_pips() with the proper modification to make them not try python3.
    Then 'pip install -r requirements.txt' worked without giving me an IncompleteRead -related traceback.
    I noticed in pip's feedback at that point that it had somehow already gotten all of the requirements installed. I don't know how, since I was getting tracebacks before then. I haven't been able to test it yet since even the smallest things take a while to figure out and I'd have to make a new machine image and step through it on the command line to be sure (otherwise I'd be testing my fabfile, which I'll probably do first since it's faster).
    Ben Friedland
    @BFriedland
    I'm currently stuck on automating database creation. I can't figure out how to get the password into the os environment without putting it in the fabfile, since for some reason calling credentials.py with execfile() did not successfully put DATABASE_PASSWORD into the os environment, even when 'if "__name__" == "__main__": set_credentials()' was placed at the bottom of the file.
    I then tried making set_credentials() return the value of the database password and tried to see if execfile() would push the results of any functions called while running it into a variable in my fabfile (using the syntax, "password_variable = execfile("./imagr_site/imagr_site/credentials.py") and the resulting value was simply 'None', which made the PSQL user on the AWS instance get created with 'None' as its password -- I was hoping I could make an automatic SQL query to delete the user and the database on the instance, but I couldn't remember how it was supposed to work and none of my google queries gave me useful StackOverflow results for some reason.
    Ben Friedland
    @BFriedland
    All the stuff requiring execfile() is probably a bad idea anyways, even if we know it's secure due to not having any holes.
    Very hackish kind of solution.
    Charlie
    @charlieRode
    I don't know if this will help, but I have been reading through this tutorial, and finding it pretty good. http://rogueleaderr.com/post/65157477648/the-idiomatic-guide-to-deploying-django-in-production
    Ben Friedland
    @BFriedland
    Hm, can't believe I didn't think to check before, but apparently any changes made to os.environ seem to be reset when I exit and reenter IDLE, so setting them by running a file outside of the python file's scope probably won't work -- in the Django settings.py file, credentials.py is simply imported, so the os.environ dictionary is not discarded between the time set_credentials() is called and when the dictionary is pinged.
    And thanks for the link, I'll look it over later. It's getting kind of late though, I think I'd better go soon.
    Charles Gust
    @CharlesGust
    Hi Ben, It's probably why you have to use "source" to set environment variables. I know when you exec a script, the variables are set only for that script, so I bet execfiles is somewhat similar.
    Ben Friedland
    @BFriedland
    Yeah, I hadn't played around with os.environ much before this assignment. Oops.
    I also haven't made too many packages previously because I'd been using less expansive frameworks, so I'm not really sure how to turn the django-imagr directory into a package itself. That would get around a tiny inconvenience with my solution to getting the fabfile to work -- I put the credentials.py file in both the root directory of our site and in the same level as settings.py, so that both the fabfile and the settings file would be able to import set_credentials() and use the os.environ dictionary for that.
    Ben Friedland
    @BFriedland
    The server needs credentials.py in the settings.py-level folder, but the fabfile on our local machine needs it in the fabfile.py-level folder. If it was a package, we could simply copy it into one place and forget about it. I decided to make a fabric function to automate transferring the credentials file from one place into another, but strictly speaking it isn't necessary to do that if you'd rather have it in two places locally.
    It's probably easy enough to make it into a package, but I've never done it before and it might be another 30-foot-deep puddle to step into...
    Ben Friedland
    @BFriedland
    I wish there was more time to clean up the fabfile and settings.py file. I also would like to alter the current github master file so I can test my fabfile (it needs to clone from github), but I don't want to overwrite your changes to the master branch without consulting with you first (Charles). I'm going to try and make a fork and get it working with that, and you can merge it into master some time tonight or tomorrow, or we can discuss the necessary changes.
    Ben Friedland
    @BFriedland
    I managed to get my copy of the fabfile running the Django-Imagr server from a single command (and one "yes" command added in halfway through).
    I think that more or less fits the description of fully automated. There is however one last problem... The account activation emails send users to an address with localhost in it, which is incorrect and I'm not sure how to fix it yet.
    Ben Friedland
    @BFriedland
    Inside our project's "imagr_site/imagr_app/templates/registration/activation_email.txt" file, it tries to construct a URL at "http://{{site.domain}}{% url 'registration_activate' activation_key %}" but I'm not sure where it's getting site.domain from. I grepped "8888" in the project directory and found that it's probably set by the server's starting command, "sudo('gunicorn -b 127.0.0.1:8888 imagr_site.wsgi:application')", since it isn't in any of our Django settings files.
    Further, in the email it says "You (or someone pretending to be you) have asked to register an account at ."
    Which implies the 'site' object that's being handed to whatever is making these registration emails inside the registration plug-in is probably using empty, default values.
    Ben Friedland
    @BFriedland
    I got the 8888 from the URL it tried to link me to, http://127.0.0.1:8888/accounts/activate/c71bb6052c694c880efe61ff7bd11d294eca83a4/
    We can bandaid-patch this by deleting {{site.domain}} in the activation_email.txt and .html files and replacing it with Charles's hosting name.
    Probably. Or we could ask Dan if this is sufficient, heh.
    Ben Friedland
    @BFriedland
    If you log in as admin, you can see test_user_zero's photo at http://ec2-54-148-67-105.us-west-2.compute.amazonaws.com/imagr_app/photo/1/
    Charles Gust
    @CharlesGust
    Hi Ben, I did the login to your site and it looks great. http://imagr.charlesgust.me has propagated DNS now, but I don't think I have gunicorn running. I was more interested in the fabfile, but given the registration email problem you've run into, that may be a better use of my time. "30-foot-deep puddle" - very apt!
    Ben Friedland
    @BFriedland
    Dan said the registration email thing was something we could ask him about in the last two days or something (December), and we'd be good turning it in now, so I'll do that later tonight. Before then we should go over how I did the fabfile and maybe delete extraneous comments, should be ~30 minutes or something I guess.
    Charles Gust
    @CharlesGust
    I actually just saw this comment, and now I see you made it this morning before we talked at lunch. Sorry I had to rush out at 4pm today; won't have to do that anytime else this week, but I never got to see if the "yes" hack worked.
    Ben Friedland
    @BFriedland
    It did, the server came up perfectly and I only noticed it hours after I started the script. So, it can probably also work on yours, with some changes to the key name and maybe copying the credentials file manually to the fabfile directory, if needed.