openhatch / oh-mainline

The code that runs openhatch.org
http://openhatch.org
GNU Affero General Public License v3.0
242 stars 310 forks source link

Move primary deployment from Linode to Heroku #1590

Open jwm opened 9 years ago

jwm commented 9 years ago

We should move our primary deployment from Linode to Heroku. We noticed recently that uWSGI hadn't picked up any changes for a few weeks, and Asheesh said he's to the point where he'd rather sacrifice a little cash for having someone handle running the deployed code.

willingc commented 9 years ago

@jwm Sounds like a good idea to me.

jwm commented 9 years ago

Still plugging away at this; converting the database data is proving to be a bit of a rabbithole, but that should be the last major thing to sort out before we can make the move.

willingc commented 9 years ago

@jwm Excellent. Selena Deckelman would be a good resource if the rabbit gets stranded in the hole ;)

paulproteus commented 9 years ago

Hi @jwm .

I noticed this issue has gone cold for a while.

I also wonder if we are trying too hard. Is there a way to use MySQL on Heroku? Can we get by with python manage.py dumpdata then python manage.py loaddata?

If you're too busy with other things, that's fine, but I don't think anyone else is tackling this so if you feel like looking into it again over the next N (1-8 weeks) that'd be glorious. And if other things in life take priority, that's fine too.

jwm commented 9 years ago

Hey @paulproteus, I had gotten pgloader working and most of the other pieces ready; sorry, this kind of got lost in everything I had to catch up with post-PyCon.

I set up a sample deployment at http://stormy-peak-6021.herokuapp.com/ (running code from https://github.com/jwm/oh-mainline/tree/jwm/heroku). I'd love it if someone could take it for a test drive and give the code changes a quick eyeball.

The gating factor right now is setting up a paid Heroku account with the sizing we need. I think a Hobby:Basic Postgres tier ($9/month) should be fine, running on a Hobby dyno ($7/month). If we need more workers than 512MB of RAM can sustain, we'll have to upgrade to a 1x dyno ($25/month) and scale up the dyno count.

Rough checklist/outline for doing the actual cut:

paulproteus commented 9 years ago

(I'm replying to an offline copy of this github thread in my email, so I might be a few days out of sync)

Just to reply to the money part of this:

OpenHatch Foundation Incorporated is fine with paying a few more dollars per month (say, up to $50/mo, without that being a big deal at all) for the sites running on Heroku rather than our own Linode. If it's more than that, we can think harder, but anything under that, assume you can just get a "yes".

paulproteus commented 9 years ago

Also, a note about my scheduled this week:

I'm at this year's Debian conference for the coming week, so won't be able to do very much on this. I massively support other people doing things and then telling me, "Asheesh, do the following whenever you can, we've tested that it will result in good things." I'll be available on+after Mon Aug 24 if you need more bandwidth from me.

If you do a database migration & test run, you'll eventually need my help to cut DNS over. For that, I can give you the password to our CloudFlare.com account, or do it myself you ping me when you need it done.

Do please first test the new site by setting up your /etc/hosts line to simulate the DNS switch.

We're going to have to update some docs after the switch, and presumably we'll remove MySQL as being one of the supported databases for development, and use sqlite+postgres as the two supported databases for development.

jwm commented 9 years ago

I crossed off the remaining TODOs today and updated the checklist in my previous comment. I also opened https://github.com/openhatch/oh-mainline/pull/1693. Everything's looking good for the cut.

@paulproteus when you have a few minutes, would you create the Heroku app and give me access to it? Something like this should get us going with the dyno and Postgres addon we need:

heroku create openhatch
heroku sharing:add jwm@horde.net
heroku addons:create heroku-postgresql:hobby-basic
heroku addons:destroy heroku-postgresql:hobby-dev
jwm commented 9 years ago

@paulproteus Also, if you would send me our CloudFlare creds in some secure way (PGP-encrypted mail? I'm on the major keyservers as well as Keybase), I'd appreciate it.

imported-from-roundup commented 9 years ago

I believe I've done the Heroku setup stuff:

➜ oh-mainline git:(master) ✗ heroku create openhatch-production Creating openhatch-production... done, stack is cedar-14 https://openhatch-production.herokuapp.com/ | https://git.heroku.com/openhatch-production.git Git remote heroku added WARNING: Toolbelt v3.41.4 update available. ➜ oh-mainline git:(master) ✗ heroku sharing add jwm@horde.net ! Invalid arguments: "add" and "jwm@horde.net" Usage: heroku sharing

list collaborators on an app

Example:

$ heroku sharing === example Collaborators collaborator@example.com collaborator email@example.com owner

Additional commands, type "heroku help COMMAND" for more details:

sharing:add EMAIL # add a collaborator to an app sharing:remove EMAIL # remove a collaborator from an app sharing:transfer TARGET # transfers an app to another user or an organization.

➜ oh-mainline git:(master) ✗ heroku sharing:add jwm@horde.net Adding jwm@horde.net to openhatch-production as collaborator... done ➜ oh-mainline git:(master) ✗ heroku addons:create heroku-postgresql:hobby-basic Creating postgresql-dimensional-4168... done, ($9.00/month) Adding postgresql-dimensional-4168 to openhatch-production... done Setting DATABASE_URL and restarting openhatch-production... done, v3 Database has been created and is available ! This database is empty. If upgrading, you can transfer ! data from another database with pgbackups:restore Use heroku addons:docs heroku-postgresql to view documentation. ➜ oh-mainline git:(master) ✗ heroku addons:destroy heroku-postgresql:hobby-dev ! Can not find add-on with "heroku-postgresql:hobby-dev"

John, I believe that's everything you need Heroku-wise, too. Note I called it openhatch-production because openhatch seems to be taken.

willingc commented 9 years ago

@jwm Nice!

jwm commented 9 years ago

@paulproteus I just realized that Cloudflare wants you to log in with an e-mail address and password, but I don't know what e-mail address OpenHatch uses for its Cloudflare account.

Also, I think this is ready to do the actual cut. What kind of advance notice should I give (to openhatch-devel@ or #openhatch?), and are there any particular days or times where the site shouldn't be down for an hour or two while I get a consistent database snapshot and do the cut?

paulproteus commented 9 years ago

Hi!

I think asheesh@openhatch.org javascript:_e(%7B%7D,'cvml','asheesh@openhatch.org'); should work for CloudFlare username.

I would say, give ~24 hours of notice to devel@lists.openhatch.org and maybe Tweet something that we can RT as @openhatch and then pick any 2 hour window that works for you.

jwm commented 9 years ago

Ok, I think the cutover to Heroku went fairly well, though it took a bit longer than I'd hoped. The site should be up, the remote command execution for git/svn repo setup works, all the database data is there, etc.

@paulproteus: a few questions, since I realized doing the cut that the Apache configuration on linode.openhatch.org is pretty sprawling and has a bunch of what looks like cruft in it:

I guess what this boils down to is... help?

Left to do/check:

willingc commented 9 years ago

@jwm Nice job documenting the migration. I created a milestone for Post Migration issues. I will wait to hear from @paulproteus and @ehashman if they wish to migrate your comments over as individual issues.

The website seems faster to load now once you get past the initial load :D

ehashman commented 9 years ago

I aggregated some of the broken link reports we were getting in #1701, looks like the wiki bit was already known now that I'm reading @jwm's comment above. Cheers!

jwm commented 9 years ago

Fixed the wiki and blog proxying.

jwm commented 9 years ago

@paulproteus looks like the openhatch-production app is running on a free dyno, and it's running out of memory. can you 'heroku dyno:type web=standard-2x' so we get some more memory?

jwm commented 9 years ago

I spent a big chunk of time poring over the nginx and Apache configurations on linode.openhatch.org. I took out large sections of the nginx configuration that aren't used any more or for sites that are now hosted elsewhere, leaving {git-mission,wiki,roundup-archive}.openhatch.org and openhatch.com. *.openhatch.org gets passed to Apache, and I wound up leaving the Apache configuration mostly alone since it's pretty sprawling and difficult to separate the wheat from the cruft. If you want to go back to the old nginx config, I init'ed a git repo in /etc/nginx before I made major changes.

I also enabled the 'Always use https' page rule at CloudFlare, which I think will replace the old nginx redirect from HTTP to HTTPS for all pages.

Additionally, I set up nightly Postgres backups at heroku (heroku pg:backups schedule DATABASE_URL --at '07:00 UTC'). I left the MySQL backups on linode.openhatch.org in place, since the Wiki and maybe other things use that MySQL server.

There are a few things that someone else should/needs to check or decide; either I don't have the access, or they're judgment calls that someone like @paulproteus should make:

I think that should be everything, other than the bugs I've opened (#1707, #1708, #1709) and the last step of the git mission, which I missed applying remote repo server support to.

Lucas-C commented 6 years ago

Hello.

With OpenHatch winding down, I guess this issue won't be solved: https://blog.openhatch.org/2017/celebrating-our-successes-and-winding-down-as-an-organization/

It's a pity, the /search page was awesome. Now all links are 2 years old and often point to closed issues.

Do you recommend any alternative ?

willingc commented 6 years ago

Hi @Lucas-C,

Thanks for the kind words. There are a few alternatives that I know of:

Lucas-C commented 6 years ago

Hey, thank you very much for your quick answer !

I couldn't find info about this new Github feature, but in the meantime I discovered http://up-for-grabs.net & http://www.firsttimersonly.com

I'm going to check https://www.codetriage.com, it looks great. It doesn't have your "mentor" feature though :(

Regards

willingc commented 6 years ago

Hmm... I thought there was a blog post on the new GitHub label "Good for New Contributors" and the new line in the projects repo header:

screenshot 2017-12-01 09 29 18

There's also this github showcase: https://github.com/showcases/great-for-new-contributors

Lucas-C commented 6 years ago

Thanks !