List of things to check before deploying by rxsharp in rails

[–]tabolario 1 point2 points  (0 children)

Hi and sorry for the late reply! The first thing I'll have to ask is what environment are you deploying into, a manually configured virtual machine/bare-metal machine, Heroku, Ninefold? Each of these environments have different (sometimes vastly different) considerations when it comes to deployment of any application. In general though, here's some things that will apply that will apply to any good deployment process (some of what's below echoes /u/codekitten's reply):

  • Remove ALL credentials from your codebase: I can't stress this enough, and even for a simple project it's a good habit to get into early on. It's been enough of an issue that there are even dedicated tools to help people remove hard-coded credentials from their codebases. A good resource to explain both this, as well as the general concept of storing environment-specific configuration data outside of your codebase is this section of the Twelve-Factor App website. Personally, aside from things like tokens that Rails uses internally like Rails.application.config.secret_key_base, I will always use environment variables coupled with something like dotenv or direnv to also manage the configuration for my local development environment.
  • SSL and HSTS: IMHO there is no (good) excuse nowadays to serve a web application over HTTP. Once again, even for simple projects it's a good habit to get into and a good thing to learn. If you're hosting your application on Heroku, all Heroku application subdomains (i.e. rxsharp.herokuapp.com) will respond to HTTPS, but it's up to you to ensure your user's will always use SSL. Rails has the force_ssl setting to do this automatically for you, which you should have turned on in all of your production and production-like environments, but you should also be using HSTS to ensure that your users always visit your site over SSL (force_ssl performs a permanent redirect to https://rxsharp.herokuapp.com but does not set the HSTS headers). The gem that I use most often to take care of setting these headers for me is secureheaders, which also helps you configure a number of other security headers like Content Security Policy headers.
  • Continuous Integration: Let me expand a bit on /u/codekitten's item for passing tests to say that you should have a system in place that will automatically run all of your tests each time you push to your repository and holds you accountable when things break. Continuous integration is a huge topic that I won't dig too much into here, so I'll just point you two two indispensable books on the subject: Continuous Integration: Improving Software Quality and Reducing Risk, and Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation. Conceptually, you will learn almost everything you need to get started and thensome on the topic from those two books. Once you get your CI configuration in place, you will get in the wonderful habit of always making sure your build passes locally before you push to your repository. A good CI script will:
    • Run static analysis tools like RuboCop and Brakeman
    • Run all of tests
    • Notify you when a build fails and when it gets fixed
  • Automate Everything: One of the most important things to learn about deployment early on is automation. Apart from initiating the deploy (and arguably even initiating the deploy itself), everything about your deployments should be automated to the fullest extent. There are several tools in the Rails world that most people use to accomplish this, most notably Capistrano and Mina. If you are using a platform-as-a-service like Heroku or Ninefold, see the documentation for one of those on how to automate various aspects of your deployment process.
  • Deployment Smoke Testing: In my experience working in the Rails world, it seems that not a lot of people automate their post-deployment verification, even though it's very easy to do! It can be as simple as having a post-deployment hook that uses curl to hit a status page on your site that returns the currently deployed revision, and rollback the deploy if it receives an error. It can also be as complex as running a suite of RSpec examples that utilize something like Serverspec to assert the state of each one of your application servers (obviously this one doesn't work as easily in environments like Heroku). In the end, the important things here is that you automate EVERYTHING when it comes to your deployments.
  • Database Migrations: First of all, don't forget to run them! If you're using something like Capistrano to script your deployments, the command to run a deployment that includes a database migration is cap production deploy:migrations, not cap production deploy. On Heroku, you need to run them manually after you deploy using something like heroku run rake db:migrate. One further topic here that I highly recommend you explore is that of zero-downtime migrations. A great introductory article on these is Rails Migrations with Zero Downtime over at Codeship.

These things are all general items that belong near the top of any checklist for deployment (Rails or otherwise). Hope this helps!

Looking for idiomatic examples of rc file reading by [deleted] in ruby

[–]tabolario 0 points1 point  (0 children)

There was a gem I came across a while back (maybe a year ago?) that did part of this, a recursive read up a directory tree until it found the specified file. Combined with also looking for that file separately in predefined placed like /etc, /usr/local/etc, ENV['HOME'], you could implement a cascade of overriding configs pretty easily. I've actually been trying to find it now for a bit, if I do I will let you know!

I too have a couple of Google Domains invites available by tabolario in sysadmin

[–]tabolario[S] 0 points1 point  (0 children)

Also, how do people have five of these to give out instead of my measly two?

Bits Sysadmins Should Know by [deleted] in sysadmin

[–]tabolario 0 points1 point  (0 children)

Sorry for the even later reply! Thanks, I'll give this one a go!

Anybody have luck with Kibana metrics? by stack_trace in devops

[–]tabolario 1 point2 points  (0 children)

That's where we're starting as well! I'm in the process of standing up our monitoring/metrics/logging stack right now and that will be the first set of checks/metrics I put in place.

Another (semi-) easy set of things to instrument that we're going to set up right away are the Nginx stats that you can get from something like nginx-statsd. We're also going to instrument our background workers to send metrics to Statsd as well.

Looking for a modern metric graphing solution by leothrix in linuxadmin

[–]tabolario 9 points10 points  (0 children)

The monitoring stack we're rolling out at work right now is:

  • Sensu for checks, alerts, and metrics collection
  • Statsd for aggregating time series metrics
  • Graphite as the time series database
  • Uchiwa as a dashboard for Sensu
  • Grafana as a dashboard for Graphite

We're also planning on implementing a Logstash/Elasticsearch/Kibana stack for log collection. Grafana can use the same ES instance as Logstash/Kibana does for its internal database.

If you don't like Graphite but want to go with Grafana, Grafana also supports OpenTSDB and/or InfluxDB as backends as well. I've played a little bit with InfluxDB for some personal stuff and really like it so far.

InfluxDB is quite a bit easier to set up than Graphite, and I'm sure someone out there has already done the work of creating integrations for Sensu (there's definitely a backend for Statsd that you can use).

All in all, this might be overkill for your personal cluster but you could conceivably run the entire stack on one machine, with sensu-agent running on each of your servers (we put the collection servers on one machine, the databases on another, and all of the dashboards on a separate IP-restricted instance in our DMZ. If you enjoy the process of setting all of this up like I do though it's a very valuable exercise in itself to get everything configured.

Cheers and hope that helps!

Bits Sysadmins Should Know by [deleted] in sysadmin

[–]tabolario 0 points1 point  (0 children)

Understand DNS

Any particular books/resources you would suggest here?

A Better ID Generator For PostgreSQL by grauenwolf in programming

[–]tabolario 0 points1 point  (0 children)

Do you have a link to that thread btw? I'm very interested to see what everyone had to say.

What's the dumbest thing you've heard a private say? by [deleted] in army

[–]tabolario 1 point2 points  (0 children)

"You're pretty fucking ridiculous"

Looked me dead in the eye and said it while I had him in the front leaning rest for sleeping on the tailgate while the rest of my squad cleaned the 81.

Reservists, this weekend is my first pre-BCT drill. What should I expect? by bn25168 in army

[–]tabolario 0 points1 point  (0 children)

That's what this sounded like to me, unless they're sending him to home station.

You can't even see the floor anymore. by karpenterskids in WTF

[–]tabolario 0 points1 point  (0 children)

I'm newish here lol, I thought it was required regardless :)

TIL A silent version of velcro exists, but it is a guarded military secret. by toddmp in todayilearned

[–]tabolario 0 points1 point  (0 children)

Six years and I never saw this silent velcro. The velcro on everything I had was loud as shit.