Contributor Interviews – Jay Pfaffman

Well, I don’t have the time to write up what I think you’re asking for, but here’s what happens. When an order is placed, I get an email that has something like this:

export NAME="Pat Doe"
export EMAIL="user@gmail.com"
export DO_HOSTNAME="forum.mysite.com"
export DO_API_KEY="thediscoursekey"
export MG_API_KEY="key-mailgunkey"
cd ~/src/discourse-installer
irb
load 'do-create-droplet'
d=DOManager.new
d.do_create_droplet("forum.mysite.com", 'nyc3', '1gb')
sleep 45
d.install_discourse

I copy and paste that into a shell. I don’t just have that in a single shell script, because if something goes wrong, I can do some stuff in my little Ruby class to fix it up.

do_create_droplet, as the name implies, creates the droplet, and adds those DNS records to the Digital Ocean DNS. If the client uses Digital Ocean as their DNS provider, all of the DNS stuff (including what Mailgun requires) happens automatically, and https gets enabled and the Mailgun domain gets verified. This isn’t advertised because I’m afraid that someone will break all their sites changing to DO’s name servers. For sites that I set up for myself, the whole thing is entirely automated.

install_discourse does what you might guess, but it also uses the Mailgun API to create the domain and get the SMTP user and password to generate an install script that

  • installs docker
  • does an apt upgrade
  • sets a root password
  • enables automatic upgrades with automatic reboot
  • turns off transparent_hugepage
  • installs git
  • installs Digital Ocean’s monitoring stuff
  • runs discourse-setup, piping in all the values as if someone had typed them.
  • reboots

The script is copied to the server and then run.

When it’s done, an email is generated with all of the DNS stuff that mailgun wants and puts it in a table with instructions that most people can follow.

The DNS settings table includes links to test the settings with G Suite Toolbox; there is also an API URL that allows the logs to be checked without logging in to Mailgun. If they do have trouble, I can generally figure out what the problem is with only what’s in the email they get.

If something goes wrong during the install, my ruby class also allows stuff like delete the droplet and start over. I also have functions to do things like:

  • discourse_to_8080(hostname = @hostname)
  • manager_install_apache
  • install_mysql(_server_ip = do_server_ip, lc_user = @lc_user)
  • create_user(_server_ip = do_server_ip, user = @lc_user)
  • install_wordpress_domain(hostname, _database, _server_ip = do_server_ip)

A feature I just added that I’m happy about is that I start monitoring the site with uptimerobot. This way I get a notification once they set up DNS and I can follow up if there’s some need to do so.

One day, Real Soon Now, I’ll finish the rails app that will let this stuff happen without my intervention.

25 Mi Piace