<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>devops &#8211; redpanthers.co</title>
	<atom:link href="/tag/devops/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Red Panthers - Experts in Ruby on Rails, System Design and Vue.js</description>
	<lastBuildDate>Tue, 13 Sep 2016 06:59:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.2.7</generator>
	<item>
		<title>Mina: Faster deployment and remote server automation</title>
		<link>/mina-faster-deployment-remote-server-automation/</link>
				<pubDate>Tue, 13 Sep 2016 06:59:08 +0000</pubDate>
		<dc:creator><![CDATA[coderhs]]></dc:creator>
				<category><![CDATA[Beginners]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[digital ocean]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mina]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">https://redpanthers.co/?p=495</guid>
				<description><![CDATA[
				<![CDATA[]]>		]]></description>
								<content:encoded><![CDATA[<p>				<![CDATA[Even though we use CodeShip/Circle CI/Jenkins for continuous integration, we still need to write scripts to automate our deployment. We also need to write small commands to clear cache, restart queues, etc. It's always a good practice to not have to enter the server directly but to have it done through scripts. There are many tools available for this purpose (in multiple languages) like Capistrano, Vlad, etc.
<a href="http://nadarei.co/mina/">Mina</a> is a similar tool, but faster. The reason why it runs faster is because it generates a bash script, uploads it to the server and run there, rather than creating a new ssh session and run every command one by one. <strong>Mina is one of our default tools at Red Panthers</strong>.
To use mina in your project, add mina to your Gemfile.


<pre class="lang:ruby decode:true">gem 'mina'</pre>


and to get started do


<pre class="lang:ruby decode:true">mina init</pre>


&nbsp;
<a href="http://nadarei.co/mina/setting_up_a_project.html">http://nadarei.co/mina/setting_up_a_project.html</a>
<a href="https://www.digitalocean.com/community/tutorials/how-to-deploy-with-mina-getting-started">https://www.digitalocean.com/community/tutorials/how-to-deploy-with-mina-getting-started</a>
&nbsp;
Having a one step deployment is an important requirement for any project so have one ready using mina or capistrano.
&nbsp;
Note:
<strong>Assets pre-compile</strong>


<pre class="prettyprint lang-rb has-caption"><span class="pln">invoke </span><span class="pun">:</span><span class="str">'rails:assets_precompile'</span></pre>


&nbsp;
<strong>Run another rake task</strong>


<pre class="lang:ruby decode:true ">invoke 'production_backup' if RAILS_ENV == 'production'</pre>


<strong>Run shell commands</strong>


<pre class="lang:sh decode:true ">queue "sudo service myapp restart"</pre>


The syntax queue is referring to the fact that, the commands are all made into a single shell script and then later executed together.
&nbsp;]]&gt;		</p>
]]></content:encoded>
										</item>
		<item>
		<title>Enable log rotation within the rails application</title>
		<link>/enable-log-rotation-within-rails-application/</link>
				<pubDate>Wed, 27 Jul 2016 05:00:19 +0000</pubDate>
		<dc:creator><![CDATA[coderhs]]></dc:creator>
				<category><![CDATA[Beginners]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[Production]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rotate]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[space]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">https://redpanthers.co/?p=359</guid>
				<description><![CDATA[
				<![CDATA[]]>		]]></description>
								<content:encoded><![CDATA[<p>				<![CDATA[Any person who has worked with a rails application for a good amount of time would have faced the issue of log files growing and consuming the entire space in the hard disk. Although this sounds funny, it does happen if you do not place a log management for your rails app (in production). You can manage your logs using log rotation. Do note that log rotation is not required if you host your app in <a href="http://heroku.com/">heroku</a>, as heroku won&#8217;t let you store files for more than 15 minutes in their server. You also do not need it if you are using some third party services like <a href="https://www.loggly.com/docs/rails-logs/">loggly</a> or <a href="https://papertrailapp.com/">papertrail</a> to manage your logs .
In the unix world, you can use log rotate service, which would be installed by default in all linux servers. But we at Red Panthers feel that everything that touches or involves our rails application should be placed along with our rails application as much as possible. If you feel the same way, it can be achieved by placing the code below in the production.rb file.


<pre class="toolbar:2 show-plain:3 lang:ruby decode:true ">config.logger = Logger.new( Rails.root.join("log", Rails.env + ".log" ), 5 , 100 * 1024 * 1024 )</pre>


The Logger.new accepts three parameters:


<ol>
 	

<li>The file name, which would be <em>production.log</em></li>


 	

<li>The number of files you want to keep</li>


 	

<li>The size of each file in bytes. (100 * 1024*1024 means 100 MB)</li>


</ol>


So, when the time comes to add the 6th 100 MB log file, it will delete the oldest.
<strong>Unix Way</strong>
For those who still want to use the unix log rotate, they should create a new config file at <code>/etc/logrotate.d/myrailsapp-config</code> as shown below


<pre class="toolbar:2 show-plain:3 lang:sh decode:true">$ cat /etc/logrotate.d/myrailsapp-config
/var/www/myrailsapp/current/log/*.log {
  compress
  copytruncate
  daily
  dateext
  delaycompress
  missingok
  rotate 90
}</pre>


In case you were wondering, here are what these options mean:


<ul>
 	

<li><b>compress</b> – Compress logs using gzip</li>


 	

<li><b>copytruncate</b> – Copy the log out of the way, and then truncate the existing logs</li>


 	

<li><b>daily</b> – Rotate daily</li>


 	

<li><b>dateext</b> – Add the date the logs were rotated as the extension instead of a number</li>


 	

<li><b>delaycompress</b> – Skip compressing the log until the following day</li>


 	

<li><b>missingok</b> – Do not raise an error when there is a missing log file</li>


 	

<li><b>rotate 90</b> – Keep up to 90 days worth of logs</li>


</ul>

]]&gt;		</p>
]]></content:encoded>
										</item>
	</channel>
</rss>
