<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gullit Miranda on Medium]]></title>
        <description><![CDATA[Stories by Gullit Miranda on Medium]]></description>
        <link>https://medium.com/@GullitMiranda?source=rss-de16875ad8ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4QSRBsY-jYmu_jUy8LIAmA.jpeg</url>
            <title>Stories by Gullit Miranda on Medium</title>
            <link>https://medium.com/@GullitMiranda?source=rss-de16875ad8ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:04:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@GullitMiranda/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Instalando Ruby on Rails na sua máquina com o azk (em minutos!)]]></title>
            <link>https://medium.com/@GullitMiranda/instalando-ruby-on-rails-na-sua-m%C3%A1quina-com-o-azk-em-minutos-94439af00511?source=rss-de16875ad8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/94439af00511</guid>
            <dc:creator><![CDATA[Gullit Miranda]]></dc:creator>
            <pubDate>Mon, 29 Jun 2015 21:21:29 GMT</pubDate>
            <atom:updated>2015-08-19T19:40:38.550Z</atom:updated>
            <content:encoded><![CDATA[<h3>Instalando Ruby on Rails<br>na sua máquina com o azk (em minutos!)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlBBFHgmShL3Eug_ZJOgxQ.jpeg" /><figcaption>&quot;essa é pra você&quot; ;)</figcaption></figure><p>To read the English version, <a href="https://medium.com/azuki-news/how-to-instail-ruby-on-rails-with-azk-on-your-local-machine-in-minutes-59d07d9e1888">click here</a>.</p><p>Somos fãs de boas ferramentas e bons serviços para desenvolvedores, principalmente daqueles bem comunicados para a comunidade.</p><p>Nesse sentido, gostamos muito da <a href="https://www.digitalocean.com/">Digital Ocean</a>.</p><p>O serviço é simples e direto, as interfaces são cuidadosamente desenhadas e preço e performance são garantidos pelo uso de <a href="https://pt.wikipedia.org/wiki/SSD">SSD</a> desde o começo.</p><p>Além disso, eles fazem um ótimo trabalho de criação de conteúdo gratuito na seção de <a href="https://www.digitalocean.com/community">comunidade</a>. Perguntas e respostas, tutoriais e galerias de ferramentas.</p><p>Hoje esbarramos em um <a href="https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04">tutorial bacana</a> para instalação de Ruby on Rails no Ubuntu usando <a href="https://github.com/sstephenson/rbenv">rbenv</a>.</p><p>Inspirados por ele, resolvemos fazer o tutorial abaixo, que visa o mesmo resultado, mas usando o <a href="https://github.com/azukiapp/azk"><strong>azk</strong></a><strong>. </strong>;)</p><p>É possível ter um ambiente de Ruby On Rails e criar uma aplicação a partir do zero em apenas 10 minutos. Você só precisa de acesso à internet e do <strong>azk</strong> instalado na sua máquina. =D</p><h4>Instalando o azk</h4><p>Se você ainda não tem o <strong>azk </strong>instalado, basta seguir a documentação oficial. É realmente muito simples e rápido.</p><ul><li>Mac OS X: <a href="http://docs.azk.io/pt-BR/installation/mac_os_x.html">http://docs.azk.io/pt-BR/installation/mac_os_x.html</a></li><li>Linux: <a href="http://docs.azk.io/pt-BR/installation/linux.html">http://docs.azk.io/pt-BR/installation/linux.html</a></li><li>Windows: a<em>inda não suportado</em></li></ul><h4>Gerando uma aplicação Ruby On Rails</h4><p>Na documentação do <strong>azk</strong>, há instruções de <a href="http://docs.azk.io/pt-BR/starting-from-scratch/">como gerar novas aplicações do zero</a> com diferentes linguagens e frameworks, como <em>Node.js</em>, <em>PHP/Laravel</em>, <em>Python/Django</em>. Vamos demonstrar aqui como gerar uma com <em>Ruby On Rails</em>.</p><pre># Obter um novo shell no contexto de uma imagem de Ruby<br>$ azk shell --image azukiapp/ruby --shell /bin/bash </pre><pre># Instalar o Ruby On Rails sem documentação <br>$ gem install rails --no-ri --no-rdoc</pre><p>O gerador de aplicação do Rails suporta uma opção chamada `<em>--database</em>`, com a qual podemos definir o banco de dados utilizado em nossa aplicação.</p><p>Abaixo, temos exemplos para três bancos de dados populares. Execute um destes comandos segundo sua preferência:</p><pre># PostgreSQL <br>$ rails new myApp --database=postgresql --skip-bundle </pre><pre># MySQL<br>$ rails new myApp --database=mysql --skip-bundle </pre><pre># SQLite<br>$ rails new myApp --skip-bundle</pre><p><strong>OBS:</strong> A opção `<em>--skip-bundle</em>` faz com que o gerador não execute o <em>`bundle install`</em> após gerar a aplicação. Não se preocupe. Durante a primeira inicialização da aplicação, o <strong>azk</strong> vai executá-lo automaticamente como parte do processo de configuração.</p><p>Para sair do shell da imagem de <em>Ruby</em> execute o comando:</p><pre>$ exit</pre><blockquote>Caso você esteja usando <strong>Linux</strong>, é preciso transferir a propriedade dos arquivos gerados para o usuário atual. Dentro do container, o Rails roda com usuário <em>root</em>, sendo assim todos os arquivos gerados serão de propriedade do <em>root. </em>Caso a configuração <em>`usuário_atual</em>:<em>grupo_principal</em>` não seja sua opção, modifique o comando abaixo como for mais adequado:</blockquote><blockquote>$ sudo chown -R `id -un`:`id -gn` myApp</blockquote><h4>Criando o arquivo Azkfile.js</h4><p>Agora que temos os arquivos da nossa aplicação <em>Rails</em>, é hora de criar o <a href="http://docs.azk.io/pt-BR/azkfilejs/">Azkfile.js</a> do projeto. Este arquivo é espinha dorsal de como <strong>azk</strong> funciona. É com ele que o <strong>azk </strong>sabe como executar sua aplicação. Felizmente, não vamos precisar escrevê-lo zero. Basta executar:</p><pre>$ cd myApp<br>$ azk init</pre><p>Pronto! Com base nos arquivos da sua aplicação, o <strong>azk</strong> foi capaz de identificar que você tinha uma aplicação <em>Rails</em> com um database e propor uma descrição de arquitetura e dependências para executar a aplicação.</p><h4>Conectando o banco de dados</h4><p>Em aplicações <em>Rails</em>, normalmente utilizamos o arquivo `<em>database.yml</em>` para configurar a conexão com o database. Por outro lado, o formato de configuração desse arquivo é muito <em>limitado. </em>Ele não oferece a flexibilidade de que precisamos para lidar com serviços que podem mudar de host e porta a cada ciclo de <em>start</em> ou <em>restart</em>.</p><p>Isso não será um problema se utilizarmos o conceito de <a href="https://pt.wikipedia.org/?title=URI">URI — Identificador Uniforme de Recursos</a>, método que tem se tornado <a href="http://12factor.net/config">padrão</a> por sua facilidade de configuração através de variáveis de ambiente.</p><p>É muito simples criarmos um `<em>database.yml</em>` personalizado, capaz de utilizar essa variável de ambiente. Para sua comodidade, já criamos <a href="https://gist.github.com/gullitmiranda/62082f2e47c364ef9617">este arquivo</a> com suporte a variável &quot;<em>DATABASE_URL&quot;, </em>que o <strong>azk</strong> vai injetar no ambiente da aplicação durante o processo de inicialização:</p><pre># Backup do arquivo original criado pelo Rails <br>$ mv config/database.yml config/database.default.yml<br> <br>$ azk shell -c &quot;curl -L <a href="http://bit.ly/1Nkuqnk">http://bit.ly/1Nkuqnk</a> -o config/database.yml&quot;</pre><h4>Executando a aplicação</h4><pre>$ azk start myApp --open</pre><p>Após apenas alguns minutos (em que o <strong>azk</strong> vai baixar e configurar todo o ambiente para você, inclusive o servidor de banco de dados), seu browser deve abrir com a seguinte página:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*cUp5wqK0OgBePmKj2HGSTw.png" /><figcaption>No detalhe da barra de endereço: o azk oferece resolução de DNS local, que evita o uso de &quot;localhost:XYZ&quot;</figcaption></figure><p>Agora basta você continuar o desenvolvimento da aplicação como faria normalmente!</p><p>Se você é novo em <em>Rails</em>, um bom ponto de partida é o <a href="http://guides.rubyonrails.org/getting_started.html"><em>Getting Started</em></a><em> </em>oficial do framework (e você nem vai precisar se preocupar com a parte da instalação). ☺</p><p>É isso!</p><p>Se você gostou, não deixe de dar uma estrela pra o <strong>azk </strong>no Github! ;)</p><p><a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a></p><p><em>Happy coding!</em><br>Time Azuki</p><h3>Mais sobre o azk</h3><p>+ Site: <a href="http://azk.io/">http://azk.io</a><br>+ Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Documentação: <a href="http://docs.azk.io/">http://docs.azk.io</a><br>+ Diretório de imagens criadas pelo time do <strong>azk</strong>: <a href="http://images.azk.io/">http://images.azk.io</a></p><h3>Contribua com o azk</h3><p>+ <em>“Star”</em> o <strong>azk </strong>no Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Reporte um problema: <a href="https://github.com/azukiapp/azk/issues/new">https://github.com/azukiapp/azk/issues/new</a><br>+ Ajude a resolver um problema reportado:<a href="https://github.com/azukiapp/azk/issues">https://github.com/azukiapp/azk/issues</a><br>+ Confira os sponsors do <strong>azk</strong>: <a href="http://azk.io/#sponsors">http://azk.io/#sponsors</a></p><h3>Fale com o time do azk</h3><p>+ Assine a newsletter semanal: <a href="http://www.azk.io/#newsletter">http://www.azk.io/#newsletter</a><br>+ Acompanhe o blog: <a href="https://medium.com/azuki-news">https://medium.com/azuki-news</a><br>+ Fale com nosso suporte (chat): <a href="https://gitter.im/azukiapp/azk/pt">https://gitter.im/azukiapp/azk/pt</a>(Português) e <a href="https://gitter.im/azukiapp/azk">https://gitter.im/azukiapp/azk</a> (English)<br>+ Facebook: <a href="https://www.facebook.com/azukiapp">https://www.facebook.com/azukiapp</a><br>+ Twitter: <a href="http://twitter.com/azukiapp">http://twitter.com/azukiapp</a><br>+ YouTube: <a href="https://www.youtube.com/user/Azukiapp/videos">https://www.youtube.com/user/Azukiapp/videos</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94439af00511" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to instaIl Ruby on Rails with azk on your local machine (in minutes!)]]></title>
            <link>https://medium.com/azuki-news/how-to-instail-ruby-on-rails-with-azk-on-your-local-machine-in-minutes-59d07d9e1888?source=rss-de16875ad8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/59d07d9e1888</guid>
            <dc:creator><![CDATA[Gullit Miranda]]></dc:creator>
            <pubDate>Mon, 29 Jun 2015 21:21:13 GMT</pubDate>
            <atom:updated>2015-08-19T19:37:14.070Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to install Ruby on Rails with azk on your local machine (in minutes!)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlBBFHgmShL3Eug_ZJOgxQ.jpeg" /><figcaption>“this one goes out for you&quot; ;)</figcaption></figure><p>Para ler a versão em Português, <a href="https://medium.com/azuki-news/instalando-ruby-on-rails-na-sua-m%C3%A1quina-com-o-azk-em-minutos-94439af00511">clique aqui</a>.</p><p>We&#39;re big fans of neat tools and services for developers, specially those well marketed to the community.</p><p>In that vibe, we really like <a href="https://www.digitalocean.com/">Digital Ocean</a>.</p><p>They offer a very simple and straightforward service, the user interfaces are carefully crafted and price &amp; performance are guaranteed by the use of <a href="https://en.wikipedia.org/wiki/Solid-state_drive">SSD</a> since the very beginning.</p><p>Plus, they do a great job creating free content on their <a href="https://www.digitalocean.com/community">community</a> section. Questions and answers, tutorials and a gallery of complementary tools.</p><p>Today, we stumbled upon this <a href="https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04">fine tutorial</a> about installing Ruby on Rails on Ubuntu using <a href="https://github.com/sstephenson/rbenv">rbenv</a>.</p><p>Inspired by that article, we decided to write own own, which gets to the same results, but using <a href="https://github.com/azukiapp/azk"><strong>azk</strong></a><strong> </strong>instead. ;)</p><p>You can have a Ruby on Rails environment to create a new application from scratch in just 10 minutes. All you&#39;ll need is internet access and <strong>azk </strong>installed on your local machine. =D</p><h4>Installing azk</h4><p>If you don&#39;t have <strong>azk </strong>installed yet, just follow our official documentation.<br>It&#39;s really simple and quick.</p><ul><li>Mac OS X: <a href="http://docs.azk.io/en/installation/mac_os_x.html">http://docs.azk.io/en/installation/mac_os_x.html</a></li><li>Linux: <a href="http://docs.azk.io/en/installation/linux.html">http://docs.azk.io/en/installation/linux.html</a></li><li>Windows: <em>not supported yet</em></li></ul><h4>Generating a Ruby On Rails application</h4><p><strong>azk</strong>&#39;s documentation offers instructions <a href="http://docs.azk.io/en/starting-from-scratch/">to generate new applications from scratch</a> using different languages and frameworks such as <em>Node.js</em>, <em>PHP/Laravel</em>, <em>Python/Django. </em>Here we&#39;ll demonstrate how to start one with <em>Ruby on Rails</em>.</p><pre># Obtain a new shell in the context of a Ruby image<br>$ azk shell --image azukiapp/ruby --shell /bin/bash</pre><pre># Install Ruby on Rails without documentation<br>$ gem install rails --no-ri --no-rdoc</pre><p>The application generator in Rails supports an option called `--<em>database</em>` which allows us to define the database for our application.</p><p>See below examples for three popular options of database. Run one of these commands to choose your favorite database:</p><pre># PostgreSQL <br>$ rails new myApp --database=postgresql --skip-bundle</pre><pre># MySQL<br>$ rails new myApp --database=mysql --skip-bundle</pre><pre># SQLite<br>$ rails new myApp --skip-bundle</pre><p><strong>OBS:</strong> The `--<em>skip-bundle</em>` option tells the generator to skip <em>`bundle install` </em>after generating the application. Don&#39;t worry. When you initialize the application for the first time, <strong>azk </strong>will run it automatically as part of the configuration process.</p><p>To leave the <em>Ruby </em>image shell run the command:</p><pre>$ exit</pre><blockquote>If you&#39;re a <strong>Linux </strong>user, you&#39;ll have to transfer the ownership of the resulting files to the current user. Since Rails runs as <em>root </em>inside the container, all of the resulting files will be <em>root. </em>If you&#39;d rather not use the <em>`current_user</em>:<em>main_group</em>` configuration, change the command below as it best suits you:</blockquote><blockquote>$ sudo chown -R `id -un`:`id -gn` myApp</blockquote><h4>Creating the Azkfile.js</h4><p>With all the files our <em>Rails</em> application will need already in place, it is time to create the project&#39;s own <a href="http://docs.azk.io/en/azkfilejs/">Azkfile.js</a>. This file is the backbone of how <strong>azk </strong>operates. That&#39;s how <strong>azk </strong>knows how to run your application. Fortunately, we won&#39;t have to write one from scratch. Just run:</p><pre>$ cd myApp<br>$ azk init</pre><p><em>Voilá!</em> Due to our application&#39;s files, <strong>azk </strong>was able to find out we have a <em>Rails </em>application with a database and then suggest an architecture and dependencies description to run your application.</p><h4>Connecting the database</h4><p>We usually use the `<em>database.yml</em>` file to configure the database connection in <em>Rails </em>applications. On the other hand, its configuration format is very <em>limited</em>. It doesn&#39;t offer all the flexibility we&#39;ll need to deal with services that can change port or host at every <em>start </em>or <em>restart </em>cycle.</p><p>But we can use the concept of <a href="https://en.wikipedia.org/wiki/Uniform_resource_identifier">URI — Uniform Resource Identifier</a>, which is becoming a <a href="http://12factor.net/config">standard</a> due to how easy it makes the configuration by using environment variables.</p><p>It&#39;s simple: we create a personalized `<em>database.yml</em>` that can use that environment variable. To make things easier <em>for you</em>, we took the liberty to prepare <a href="https://gist.github.com/gullitmiranda/62082f2e47c364ef9617">this file</a> with support to the variable “<em>DATABASE_URL”, </em>which <strong>azk </strong>will inject on our application&#39;s environment during initialization:</p><pre># Backup of the original file created by Rails<br>$ mv config/database.yml config/database.default.yml</pre><pre>$ azk shell -c &quot;curl -L <a href="http://bit.ly/1Nkuqnk">http://bit.ly/1Nkuqnk</a> -o config/database.yml&quot;</pre><h4>Running the application</h4><pre>$ azk start myApp --open</pre><p>After just a few minutes (during which <strong>azk </strong>will configure all the environment for you, including the database), your browser should open and display this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*cUp5wqK0OgBePmKj2HGSTw.png" /><figcaption>Notice the address bar: azk offers DNS resolution that prevents the use of “localhost:XYZ”</figcaption></figure><p>Now you can continue developing your new <em>Rails </em>application as you normally would!</p><p>If you&#39;re new to <em>Rails, </em>we recommend the framework&#39;s own official <a href="http://guides.rubyonrails.org/getting_started.html"><em>Getting Started</em></a><em> </em>(and you&#39;ll even be able to skip the installation part on it). ☺</p><p>That&#39;s it!</p><p>If you liked this brief tutorial, please, don&#39;t forget to give <strong>azk </strong>a star on Github! ;)</p><p><a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a></p><p><em>Happy coding!</em><br>Azuki Team</p><h3>More about azk</h3><p>+ Site: <a href="http://azk.io/">http://azk.io</a><br>+ Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Documentation: <a href="http://docs.azk.io/">http://docs.azk.io</a><br>+ Images directory created by the <strong>azk </strong>team: <a href="http://images.azk.io/">http://images.azk.io</a></p><h3>Contribute to azk</h3><p>+ <em>Star</em> <strong>azk </strong>on<strong> </strong>Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Report an issue: <a href="https://github.com/azukiapp/azk/issues/new">https://github.com/azukiapp/azk/issues/new</a><br>+ Help solving a reported issue: <a href="https://github.com/azukiapp/azk/issues">https://github.com/azukiapp/azk/issues</a><br>+ Check out our awesome sponsors: <a href="http://azk.io/#sponsors">http://azk.io/#sponsors</a></p><h3>Stay in touch with the azk team</h3><p>+ Sign up the weekly digest: <a href="http://www.azk.io/#newsletter">http://www.azk.io/#newsletter</a><br>+ Follow the blog: <a href="https://medium.com/azuki-news">https://medium.com/azuki-news</a><br>+ Talk to our support (chat): <a href="https://gitter.im/azukiapp/azk">https://gitter.im/azukiapp/azk</a> (English) and <a href="https://gitter.im/azukiapp/azk/pt">https://gitter.im/azukiapp/azk/pt</a> (Português)<br>+ Facebook: <a href="https://www.facebook.com/azukiapp">https://www.facebook.com/azukiapp</a><br>+ Twitter: <a href="http://twitter.com/azukiapp">http://twitter.com/azukiapp</a><br>+ YouTube: <a href="https://www.youtube.com/user/Azukiapp/videos">https://www.youtube.com/user/Azukiapp/videos</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59d07d9e1888" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azuki-news/how-to-instail-ruby-on-rails-with-azk-on-your-local-machine-in-minutes-59d07d9e1888">How to instaIl Ruby on Rails with azk on your local machine (in minutes!)</a> was originally published in <a href="https://medium.com/azuki-news">Azuki News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[azk CLI: como melhoramos a central de comando do azk]]></title>
            <link>https://medium.com/@GullitMiranda/azk-cli-como-melhoramos-a-central-de-comando-do-azk-e0c659d94dc3?source=rss-de16875ad8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0c659d94dc3</guid>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[azk]]></category>
            <dc:creator><![CDATA[Gullit Miranda]]></dc:creator>
            <pubDate>Wed, 17 Jun 2015 18:38:27 GMT</pubDate>
            <atom:updated>2015-06-17T19:29:47.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_Uxcju7kz-9HFQxQw62jA.jpeg" /><figcaption>&quot;ground control to Major Tom…&quot;</figcaption></figure><p>To read the English version, <a href="https://medium.com/azuki-news/azk-cli-how-we-made-the-azk-command-center-better-c275dcc86872">click here</a>.</p><p>Estamos lançando o <a href="https://github.com/azukiapp/azk/blob/master/CHANGELOG.md#v0140---2015-06-16">azk v0.14.0</a> e, tal como explicamos no seu <a href="https://medium.com/@felipe.arenales/azk-v0-14-0-a-jornada-%C3%A9-a-recompensa-b8b7489e80d3"><strong>artigo de lançamento aqui</strong></a> no blog, a refatoração da CLI (<em>command line interface) </em>do <strong>azk </strong>foi uma das grandes novidades desta versão.</p><p>Falaremos um pouco mais aqui sobre a motivação dessas mudanças e como as fizemos.</p><h3>Motivação</h3><p>Hoje, a CLI do <strong>azk </strong>é sua única interface de uso (<em>ainda…</em>). Ela é o centro de operações através do qual toda e qualquer tarefa é executada.</p><p>Sua <em>performance</em> e sua <em>usabilidade</em> são cruciais para o melhor aproveitamento do <strong>azk</strong>.</p><p>Embora ela não tivesse a mesma performance de execução de um <a href="https://en.wikipedia.org/wiki/Grep">grep</a> ou um de <a href="https://en.wikipedia.org/wiki/AWK">awk</a>, a CLI do <strong>azk </strong>não era exatamente lenta. Por outro lado, essas próprias referências já eram indicação para nós de que ainda havia espaço para melhorar a performance da CLI.</p><p>Uma redução de milésimos de segundo na execução e resposta de um único comando não faz muita diferença, mas numa única sessão de uso do <strong>azk</strong> vários comandos podem ser dados. E se quisermos que o <strong>azk</strong> realmente se torne um padrão de desenvolvimento, ele certamente será usado várias vezes por dia por um mesmo usuário.</p><p>Aqueles milésimos de segundos começam a fazer diferença nesse cenário.</p><p>Cremos que o mesmo vale para a usabilidade da CLI. Por isso tivemos cuidados especiais com a <em>formação dos comandos</em>, a <em>estilização dos outputs</em> e com os <em>recursos de ajuda</em> na CLI.</p><p>Todas essas coisas devem funcionar como uma segunda natureza para o nosso usuário e precisam se tornar tão automáticas para ele quanto respirar.</p><p>O desafio não foi pequeno. Em versões anteriores do <strong>azk</strong>, tínhamos optado por construir nosso próprio parser, o que resultou em alguns problemas de performance e nos levou a outra questão, como explicamos abaixo.</p><h3>Padrão Unix</h3><p>Embora o <strong>azk </strong>não tenha sido criado como mera interface de uso para o <a href="https://www.docker.com/">Docker</a>, muitos dos seus recursos são possíveis pelo uso de <a href="http://a16z.com/2015/01/22/containers/">containers</a> em seu <em>core.</em></p><p>Assim, por uma questão de facilidade de uso, optamos por seguir o mesmo comportamento de CLI já oferecido pelo Docker.</p><p>Isso significa que o <strong>azk</strong> interpretava as opções passadas à CLI segundo a sequência delas quando passadas a um dado comando, o que levava a alguns problemas. Por exemplo:</p><pre>$ azk --log=debug start <br>$ azk start --log=debug</pre><p>Apesar da similaridade entre os comandos acima, eles não teriam o mesmo efeito. O primeiro iria funcionar, mas o segundo iria falhar (e avisaria que o <em>`--log=debug`</em> não é uma opção válida para o comando <em>start</em>).</p><p>No mundo Unix, o correto é suportar qualquer sequência para as opções passadas a um comando. Em nossa decisão precoce de suportar no <strong>azk </strong>um comportamento e CLI similar ao do Docker, decidimos desenvolver nosso próprio <em>parser</em> de comandos, mas isso tornou o trabalho de manutenção da CLI complicado.</p><p>A CLI se tornou limitada, de difícil manutenção e ainda deixou a desejar no quesito de usabilidade.</p><p>Algumas opções passadas ao comando precisavam estar na ordem ou sequência determinada, o <em>help</em> só poderia ser chamado de forma muito específica e era inviável gerar um <em>“Auto Complete”</em> (que lista as opções de comando e formatacão disponíveis enquanto se digita, quando você pressionar <em>tab </em>no teclado).</p><h3>Soluções</h3><p><em>Performance</em> e <em>usabilidade</em> sempre serão prioridades no <strong>azk</strong>. Não adianta o <strong>azk</strong> ser “mágico” em suas funcionalidades se ele for lento ou pouco intuitivo de se usar.</p><p>Para solucionarmos os problemas listados anteriormente, vamos primeiro recapitular os requisitos. A CLI deve:</p><ul><li>ser <em>“unix standard” </em>ou Posix;</li><li>ser fácil de usar;</li><li>ter baixo tempo de resposta;</li><li>ser facilmente modificável (para fins de evolução);</li><li>oferecer uma forma fácil de suportar <em>&quot;Auto Complete&quot; </em>no terminal.</li></ul><h4>Primeira parte: seguindo o padrão Unix</h4><p>Depois de várias pesquisas encontramos uma solução que atendia aos requisitos acima e usava uma abordagem nova para um problema conhecido. Trata-se de uma ferramenta que faz o <em>parsing</em> das opções passadas a um comando com base no <em>help</em> de uso do comando.</p><p>Esta ferramenta é o <a href="http://docopt.org/"><strong>Docopt</strong></a>.</p><p>Mais que uma simples implementação das funções acima, ele está se tornando um verdadeiro padrão de como se tratar o <em>parsing</em> de comandos na CLI. Além de uma rica documentação de opções de comandos Unix, ele ainda oferece implementações para diferentes linguagens, incluindo JavaScript (linguagem de implementação dessas funções no <strong>azk</strong>).</p><p>Com o Docopt, encontramos a primeira parte da nossa solução. Restava então solucionar a questão da execução de ações uma vez que o Docopt tivesse <em>&quot;parseado&quot;</em> as opções passadas aos comandos na CLI.</p><h4>Segunda parte: performance e modularização</h4><p>Como tínhamos implementado nosso próprio parser no <strong>azk</strong>, acabamos com um complexo sistema de classes e heranças. Se, por um lado, ele facilitava o <em>load</em> dos comandos e das opções suportadas pelo parser, por outro, ele era muito pesado e monolítico, o que tornava a CLI lenta e difícil evolução.</p><p>Apesar de poderoso e versátil, o Docopt não resolve a questão de endereçamento das opções &quot;parseadas&quot; por ele. Precisávamos então de um sistema de “rotas” que chamasse o “código” responsável por cada comando propriamente dito com base nas opções extraídas pelo Docopt.</p><p>Evitamos a tentação de modificar o Docopt e acabarmos criando um outro “monolito” e partimos para uma abordagem comum em frameworks web: um sistema de <strong>rotas </strong>e <strong>controladores</strong>.</p><p>Para ligar as opções &quot;parseadas&quot; pelo Docopt com as devidas ações, construímos o <a href="https://www.npmjs.com/package/cli-router"><strong>cli-router</strong></a>.</p><h4>Nasce o <a href="https://www.npmjs.com/package/cli-router">cli-router</a></h4><p>O <em>cli-router</em> nada mais é do que uma implementação simples de um <em>router:</em> um conceito onde uma série de regras guiam a decisão de qual ação (<em>controller</em>) deve ser chamada.</p><p>Você pode encontrá-lo <a href="https://www.npmjs.com/package/cli-router">aqui</a>.</p><p>Com base em uma serie de filtros ou regras, o cli-router é capaz de olhar para os parâmetros e decidir quem ele deve chamar.</p><p>Vejamos um exemplo simples:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b113992c0666912c52f71134b6cf5b4b/href">https://medium.com/media/b113992c0666912c52f71134b6cf5b4b/href</a></iframe><p>Explicação das rotas:</p><ul><li><em>help</em>: se o comando for<em> help</em>, se a opção <em>&quot;--help&quot;</em> existir ou se o comando não possuir nenhum argumento, chama o controlador <em>“Help”</em>;</li><li><em>version</em>: se o comando for <em>version </em>ou se a a opção <em>&quot;--version&quot;</em> existir, chama o controlador <em>“Version”</em>;</li><li><em>hello</em>: como aqui não foi passado nenhum filtro, o cli-router automaticamente cria um filtro que verifica se o comando é igual ao nome da rota, que neste caso é <em>“hello”</em>.</li></ul><h4>E o <em>help</em>?</h4><p>Uma das coisas de que temos orgulho no <strong>azk</strong> é o seu <em>help.</em></p><p>Além de flexível, ele era construído dinamicamente com base nas opções passadas ao nosso antigo parser.</p><p>Com a mudança para o <strong><em>cli-router</em></strong> e o <strong>Docopt</strong>, abrimos mão dessa implementação e precisamos de uma nova abordagem. Graças à flexibilidade da nova abordagem, construir um novo sistema de <em>help</em> se revelou fácil e ainda nos permitiu criar melhorias como o sistema de <em>“Auto Complete”</em>.</p><p>O <em>cli-router</em> possui um único controlador chamado <em>help</em>, que é capaz de deixar o <em>help</em> da CLI dinâmico. Por exemplo: caso você chame o <em>help</em> de um comando específico, ele extrai as informações pertinentes e retorna um novo help.</p><p>Esse controlador foi desenvolvido para ser extensível. Assim é possível aplicar alterações e estilizações específicas para cada aplicação. No <strong>azk</strong>, por exemplo, herdamos o controlador de <em>help</em> para que os títulos sejam coloridos.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f37d934f6b092390a413cc262b2e1b0/href">https://medium.com/media/7f37d934f6b092390a413cc262b2e1b0/href</a></iframe><p>Para visualizar o <em>help</em> global:</p><pre>$ azk --help</pre><p>Para visualizar o <em>help</em> apenas do comando agent:</p><pre>$ azk agent --help</pre><p>Gostaríamos de ressaltar que, apesar de ser empregada no <strong>azk</strong>, a biblioteca <a href="https://www.npmjs.com/package/cli-router"><strong>cli-router</strong></a> é um projeto open source independente e seu uso não depende do <strong>azk</strong>. Fique à vontade para utilizá-la para construir sua própria ferramenta de CLI. :)</p><h3>Conclusão</h3><p>A CLI do <strong>azk </strong>é a única central de comando da ferramenta para o usuário final (<em>ainda…)</em>. Performance e facilidade de uso são requisitos centrais para o seu uso.</p><p>Demonstramos aqui como pensamos a evolução da CLI e as medidas que tomamos a fim de pô-la em prática.</p><p>Sabemos que, para se tornar o padrão universal de desenvolvimento que esperamos que o <strong>azk </strong>seja, ele <strong>nunca estará completo</strong>. Sempre haverá muito o que fazer para ele melhorar e atender o enésimo cenário de uso.</p><p>Como o <strong>azk </strong>é software de código aberto, buscamos com mais este exemplo de evolução de um componente do <strong>azk </strong>discutir &quot;em público&quot; o esforço envolvido na criação da ferramenta.</p><p>Podem continuar a contar com este tipo de esforço e de ritmo de evolução do <strong>azk </strong>vindos do nosso <em>core team</em>.</p><p>Como sempre, esperamos ansiosamente pelo dia em que, além disso, o <strong>azk </strong>possa contar também com ainda mais contribuições vindas de fora do nosso time.</p><p>Não deixe de conferir os links abaixo com as inúmeras formas de entrar em contato e de contribuir (e não apenas com código).</p><p>Pra começar, não esqueça de dar uma &quot;estrela&quot; para o <strong>azk </strong>no Github! ;)</p><p><a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a></p><p>Valeu, pessoal!<em><br>Time Azuki</em></p><h3>Mais sobre o azk</h3><p>+ Site: <a href="http://azk.io/">http://azk.io</a><br>+ Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Documentação: <a href="http://docs.azk.io/">http://docs.azk.io</a><br>+ Diretório de imagens criadas pelo time do <strong>azk</strong>: <a href="http://images.azk.io/">http://images.azk.io</a></p><h3>Contribua com o azk</h3><p>+ <em>“Star”</em> o <strong>azk </strong>no Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Reporte um problema: <a href="https://github.com/azukiapp/azk/issues/new">https://github.com/azukiapp/azk/issues/new</a><br>+ Ajude a resolver um problema reportado: <a href="https://github.com/azukiapp/azk/issues">https://github.com/azukiapp/azk/issues</a><br>+ Confira os sponsors do <strong>azk</strong>: <a href="http://azk.io/#sponsors">http://azk.io/#sponsors</a></p><h3>Fale com o time do azk</h3><p>+ Assine a newsletter semanal: <a href="http://www.azk.io/#newsletter">http://www.azk.io/#newsletter</a><br>+ Acompanhe o blog: <a href="https://medium.com/azuki-news">https://medium.com/azuki-news</a><br>+ Fale com nosso suporte (chat): <a href="https://gitter.im/azukiapp/azk/pt">https://gitter.im/azukiapp/azk/pt</a> (Português) e <a href="https://gitter.im/azukiapp/azk">https://gitter.im/azukiapp/azk</a> (English)<br>+ Facebook: <a href="https://www.facebook.com/azukiapp">https://www.facebook.com/azukiapp</a><br>+ Twitter: <a href="http://twitter.com/azukiapp">http://twitter.com/azukiapp</a><br>+ YouTube: <a href="https://www.youtube.com/user/Azukiapp/videos">https://www.youtube.com/user/Azukiapp/videos</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0c659d94dc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[azk CLI: how we made the azk command center better]]></title>
            <link>https://medium.com/azuki-news/azk-cli-how-we-made-the-azk-command-center-better-c275dcc86872?source=rss-de16875ad8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/c275dcc86872</guid>
            <dc:creator><![CDATA[Gullit Miranda]]></dc:creator>
            <pubDate>Wed, 17 Jun 2015 18:38:00 GMT</pubDate>
            <atom:updated>2015-06-18T13:15:35.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_Uxcju7kz-9HFQxQw62jA.jpeg" /><figcaption>“ground control to Major Tom…”</figcaption></figure><p>To read the Portuguese version, <a href="https://medium.com/@GullitMiranda/azk-cli-como-melhoramos-a-central-de-comando-do-azk-e0c659d94dc3">click here</a>.</p><p>We are launching <a href="https://github.com/azukiapp/azk/blob/master/CHANGELOG.md#v0140---2015-06-16">azk v0.14.0</a> and as we explain <a href="https://medium.com/azuki-news/azk-v0-14-0-the-journey-is-the-reward-60ea7a5c80e7"><strong>elsewhere in our blog</strong></a>, rebuilding the <strong>azk </strong>CLI (<em>command line interface</em>) from the ground up is a big part of this new version.</p><p>Here we’ll talk in detail about why and how we did it.</p><h3>Motivation</h3><p>Today, the <strong>azk </strong>CLI is its only user interface (<em>as of yet…</em>). It is the operations center from which every and any task is commanded.</p><p><em>Performance </em>and <em>usability</em> are paramount to the best possible <strong>azk </strong>experience.</p><p>Although the CLI didn’t have the same high performance of utilities such as <a href="https://en.wikipedia.org/wiki/Grep">grep</a> or <a href="https://en.wikipedia.org/wiki/AWK">awk</a>, the <strong>azk </strong>CLI wasn’t exactly slow. On the other hand, these very references were indications that there was room for improvement for our CLI.</p><p>Cutting off milliseconds from the execution and response time of a single command may not make a big difference, but many commands may be executed on a single use session of <strong>azk</strong>. If we’re dead serious about making <strong>azk </strong>a software development standard (<em>and boy, we are!</em>), it certainly will be used many times a day by any single user.</p><p>Those milliseconds eventually pile up.</p><p>We believe that the same applies to the CLI usability. That’s why we took extra care with <em>commands formation</em>, <em>output stylization</em> and <em>help resources</em> on the CLI.</p><p>All those things must be like a second nature to our user, as automatic for him as <em>breathing</em>.</p><p>That was no small challenge. In previous versions, we had decided to build our own parser for <strong>azk</strong>, which brought some performance issues and another kind of problem as we discuss below.</p><h3>The Unix Standard</h3><p>Although we haven’t created <strong>azk </strong>as a mere user interface for <a href="https://www.docker.com/">Docker</a>, many of its features are only possible due to the use of <a href="http://a16z.com/2015/01/22/containers/">containers</a> on its core.</p><p>Thus, for practical reasons at the time, we just employed the same CLI behavior offered by Docker.</p><p>That meant <strong>azk </strong>would interpret the options passed on to the CLI according to their sequence in a given command. That resulted in problems like the one below:</p><pre>$ azk --log=debug start <br>$ azk start --log=debug</pre><p>Even though the commands above look similar, they wouldn’t effect the same results. The first one would work, but the second one would fail (and would inform that <em>`--log=debug` </em>is not a valid option to the <em>start </em>command).</p><p>In the Unix world, supporting any options sequence passed on to any command is the correct behavior. In our early decision to support a Docker-like CLI behavior on <strong>azk</strong>, we decided to build our own commands parser, but that only made the CLI maintenance more complicated than it needed to be.</p><p>The CLI was limited, hard to maintain and could have had better usability.</p><p>Some options had to be passed on to the commands precisely in right sequence, <em>help </em>could only be called in a very specific way and it became impossible to generate “<em>Auto Complete” </em>(which lists options that can be passed to a command as you type when you hit <em>tab</em> on the keyboard).</p><h3>Solutions</h3><p><em>Performance</em> and <em>usability</em> will always be key priorities on <strong>azk</strong>. It is no use to make <strong>azk </strong>“magical” in its features if it is slow or not so intuitive to use.</p><p>So, before we try and solve the problems listed before, let’s first recap the requisites. The CLI must:</p><ul><li>be <em>“unix standard” </em>or Posix;</li><li>be easy to use;</li><li>display very low response times;</li><li>be easily changeable (so that it can evolve well);</li><li>support easy implementation of <em>“Auto Complete” </em>on the terminal.</li></ul><h4>Part one: following the Unix way</h4><p>After some research, we found a solution that addressed the requisites and brought a new approach to an old problem. It’s a tool that <em>parses</em> the options passed on to a given command based on the command <em>help.</em></p><p>This tool is <a href="http://docopt.org/"><strong>Docopt</strong></a>.</p><p>More than just an implementation of those requisites, Docopt is becoming a true standard for <em>parsing </em>commands on the CLI. On top of rich documentation of Unix commands options it also offers implementations for different languages, including JavaScript (which we used to implement those features on <strong>azk).</strong></p><p>With Docopt, we found the first part of the solution we were looking for, but we still had to find out how to execute the correct actions after Docopt had <em>parsed </em>the options attached to each command on the CLI.</p><h4>Part two: performance and modularization</h4><p>As we built our own parser for <strong>azk</strong>, we ended up with a complex system of classes and inheritances. On one hand, it made <em>load</em> easier for commands and options supported by the parser, but it was also quite heavy and monolithic on the other hand and that made the CLI really hard to evolve.</p><p>Even as powerful and versatile as Docopt proved to be, it couldn’t direct or address the options it parsed. We needed a “routes” system that invoked the right piece of code responsible for each command based on the options extracted by Docopt.</p><p>We avoided the temptation of modifying Docopt and end up with another “monolith” and followed a common approach in web frameworks: <strong>routes </strong>and <strong>controllers</strong>.</p><p>So, in order to connect the options parsed by Docopt to the right actions, we built <a href="https://www.npmjs.com/package/cli-router"><strong>cli-router</strong></a>.</p><h4><a href="https://www.npmjs.com/package/cli-router">cli-router</a> is born</h4><p><em>cli-router</em> is nothing more that a simple <em>router </em>implementation: a concept where a series of rules guide the decision of which action (<em>controller)</em> to call.</p><p>You can find it <a href="https://www.npmjs.com/package/cli-router">here</a>.</p><p>Based on filters and rules, cli-router can look at command parameters and choose actions to call.</p><p>For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b113992c0666912c52f71134b6cf5b4b/href">https://medium.com/media/b113992c0666912c52f71134b6cf5b4b/href</a></iframe><p>Explaining the routes:</p><ul><li><em>help</em>: if the command is <em>help</em>, if the “ --<em>help” </em>option exists or if the command doesn’t have any arguments, calls the “<em>Help</em>” controller;</li><li><em>version</em>: if the command is <em>version</em> or if the “--<em>version” </em>option exists, calls the <em>“Version”</em> controller;</li><li><em>hello</em>: since no filter was passed on, cli-router automatically creates a filter that verifies if the command is equal to the route name which in this case is “<em>hello</em>”.</li></ul><h4>What about the help?</h4><p><em>help </em>on <strong>azk </strong>is one of the many things we’re proud of.</p><p>It was flexible and dynamically built based on the options passed on to our old home built parser.</p><p>When we adopted <strong><em>cli-router</em></strong> and <strong>Docopt</strong>, we gave up that implementation and needed a new approach. Thanks to the flexibility of that new approach, building a new <em>help</em> system turned out to be easy and also allowed us to make improvements such as the <em>“Auto Complete” </em>system.</p><p><em>cli-router</em> has a single controller called <em>help</em>, capable of making the CLI <em>help</em>dynamic. For example: if you call <em>help </em>for a specific command, it extracts pertinent information and returns a new help.</p><p>This controller was built to be extensible. Thus it is possible to apply specific alterations and stylizations to each application. For example, with <strong>azk </strong>we inherited the <em>help </em>controller so that titles can have different colors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f37d934f6b092390a413cc262b2e1b0/href">https://medium.com/media/7f37d934f6b092390a413cc262b2e1b0/href</a></iframe><p>To visualize the global <em>help:</em></p><pre>$ azk --help</pre><p>To visualize just the agent command <em>help</em>:</p><pre>$ azk agent --help</pre><p>We’d like to point out that although the <a href="https://www.npmjs.com/package/cli-router"><strong>cli-router</strong></a><strong> </strong>is part of <strong>azk</strong>, it is also a stand alone open source project and its use doesn’t depend on <strong>azk</strong>. Please, feel free to use it to build your own CLI tool. :)</p><h3>Conclusion</h3><p>The <strong>azk </strong>CLI is the only command center available to the final user <em>(yet…). </em>Performance and ease-of-use are key requisites for its use.</p><p>We have shown here how we think about the CLI evolution and the measures we took to implement it.</p><p>Since <strong>azk </strong>is open source software, we tried to publicly discuss the effort applied to its creation and evolution.</p><p>We know that in order to be the universal standard we hope <strong>azk </strong>becomes, it will <strong>never be finished</strong>. There will always be lots to do so that it can address that <em>nth </em>new scenario.</p><p>You can keep on counting on that kind of effort and evolution pace for <strong>azk </strong>coming from our core team.</p><p>As always, we look forward to the day when <strong>azk </strong>can also count on contributions from outside the team.</p><p>Don’t forget to check the links below with the many ways you can stay in touch with us and start to contribute (and not only with code).</p><p>And, please, don’t forget to give a “star” to <strong>azk </strong>on Github! ;)</p><p><a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a></p><p>That’s all for today, folks! Thanks!<em><br>Time Azuki</em></p><h3>More about azk</h3><p>+ Site: <a href="http://azk.io/">http://azk.io</a><br>+ Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Documentation: <a href="http://docs.azk.io/">http://docs.azk.io</a><br>+ Images directory created by the <strong>azk </strong>team: <a href="http://images.azk.io/">http://images.azk.io</a></p><h3>Contribute to azk</h3><p>+ <em>Star</em> <strong>azk </strong>on<strong> </strong>Github: <a href="https://github.com/azukiapp/azk">https://github.com/azukiapp/azk</a><br>+ Report an issue: <a href="https://github.com/azukiapp/azk/issues/new">https://github.com/azukiapp/azk/issues/new</a><br>+ Help solving a reported issue: <a href="https://github.com/azukiapp/azk/issues">https://github.com/azukiapp/azk/issues</a><br>+ Check out our awesome sponsors: <a href="http://azk.io/#sponsors">http://azk.io/#sponsors</a></p><h3>Stay in touch with the azk team</h3><p>+ Sign up the weekly digest: <a href="http://www.azk.io/#newsletter">http://www.azk.io/#newsletter</a><br>+ Follow the blog: <a href="https://medium.com/azuki-news">https://medium.com/azuki-news</a><br>+ Talk to our support (chat): <a href="https://gitter.im/azukiapp/azk">https://gitter.im/azukiapp/azk</a> (English) e<a href="https://gitter.im/azukiapp/azk/pt">https://gitter.im/azukiapp/azk/pt</a> (Português)<br>+ Facebook: <a href="https://www.facebook.com/azukiapp">https://www.facebook.com/azukiapp</a><br>+ Twitter: <a href="http://twitter.com/azukiapp">http://twitter.com/azukiapp</a><br>+ YouTube: <a href="https://www.youtube.com/user/Azukiapp/videos">https://www.youtube.com/user/Azukiapp/videos</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c275dcc86872" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azuki-news/azk-cli-how-we-made-the-azk-command-center-better-c275dcc86872">azk CLI: how we made the azk command center better</a> was originally published in <a href="https://medium.com/azuki-news">Azuki News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Orquestrando ambiente do UMRUM com azk.]]></title>
            <link>https://medium.com/@GullitMiranda/orquestrando-ambiente-do-umrum-com-azk-a0424389d9ba?source=rss-de16875ad8ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0424389d9ba</guid>
            <category><![CDATA[umrum]]></category>
            <category><![CDATA[azk]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Gullit Miranda]]></dc:creator>
            <pubDate>Thu, 12 Feb 2015 01:48:51 GMT</pubDate>
            <atom:updated>2015-03-21T22:20:27.061Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/114/1*4KtKS-z6m1XFps7D7Jccsg.png" /></figure><p>No dia 09 de fevereiro, meu amigo <a href="https://twitter.com/marcusgadbem">@marcusgadbem</a> me procurou para auxiliá-lo a implantar o <a href="http://azk.io/">azk</a> em um projeto ao qual ele contribui, conhecido como <a href="http://umrum.io/">UMRUM</a>.</p><h3>O UMRUM</h3><p>UMRUM = Ultimate Magic Realtime User Monitoring.</p><p>O UMRUM é um projeto brasileiro e open source feito em node.js, para monitoramento e analytics de usuário em tempo real. Ele surgiu a partir de um hackathon internacional de Node.js em 2013.</p><h4>&quot;Mão na Massa (código)&quot;</h4><h3>Instalação do azk (no Mac):</h3><p>Seguindo a <a href="http://docs.azk.io/pt-BR/installation/index.html">documentação</a> do azk fizemos, a instalação do mesmo e do Virtualbox através do brew:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cca7ff0add778d24c4c85b17ada0ca3/href">https://medium.com/media/0cca7ff0add778d24c4c85b17ada0ca3/href</a></iframe><h3>Azkfile.js</h3><p>Depois do azk instalado vamos criar o nosso <a href="http://docs.azk.io/pt-BR/azkfilejs/index.html">Azkfile.js</a> para definir a estrutura da aplicação do UMRUM.</p><p>O azk possui um comando ao qual ele lê seu código e sugere um Azkfile.js o mais preciso possível:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2860cd2c2d8c05ddbeb08fb0c312fa3/href">https://medium.com/media/a2860cd2c2d8c05ddbeb08fb0c312fa3/href</a></iframe><p>Seguindo as instruções do gerador do azk, adicionamos a pasta <strong>`.azk`</strong> ao `.gitignore` do projeto.</p><p>O Azkfile.js gerado:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11190593149eec8e10831f43e0a46f58/href">https://medium.com/media/11190593149eec8e10831f43e0a46f58/href</a></iframe><p>O Azkfile.js gerado pelo azk ainda não satisfaz as necessidades do UMRUM, pois identificou apenas o node.js. Agora vamos adicionar as dependências de MongoDB e Redis.</p><h3>Adicionando dependências</h3><h4>(Redis e o MongoDB):</h4><p>Nessa etapa vamos precisar editar o Azkfile.js, para adicionar o Redis e o MongoDB, e coloca-lôs como dependências para a aplicação principal do UMRUM.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b39f8656a9cd2002d2e60415e9026f52/href">https://medium.com/media/b39f8656a9cd2002d2e60415e9026f52/href</a></iframe><p>Entenda as alterações feitas:</p><p>— <a href="http://docs.azk.io/pt-BR/azkfilejs/depends.html"><strong>depends</strong></a>: Definimos quais dependências são necessárias para que o UMRUM seja levantado. O azk carrega as variáveis de ambiente exportadas (`export_envs`) pelas dependências junto com o contexto da aplicação. Ex: Como o sistema mongodb é uma dependência do sistema `umrum`, a variável de ambiente `MONGODB_URI` estará disponível no contexto do umrum, ou seja, na aplicação é possível utilizar essa variável para fazer a conexão com o MONGODB.</p><p>— <a href="http://docs.azk.io/pt-BR/azkfilejs/provision.html"><strong>provision</strong></a>: Adicionamos o `grunt compile` para que quando o sistema for provisionado a task seja executada após o `npm install`.</p><p>— <a href="http://docs.azk.io/pt-BR/azkfilejs/command.html"><strong>command</strong></a>: Definimos que `grunt server` é o comando que será executado todas as vezes que o sistema for levantado ou escalonado.</p><p><strong>— </strong><a href="http://docs.azk.io/pt-BR/azkfilejs/wait.html"><strong>wait</strong></a><strong>:</strong> Alteramos o <strong>`timeout`</strong> (tempo de cada tentativa de conexão) com a aplicação para 10000ms.</p><p><strong>— </strong><a href="http://docs.azk.io/pt-BR/azkfilejs/ports.html"><strong>ports</strong></a><strong>:</strong> Define quais são as portas que serão utilizadas para que o balanceador de carga do azk possa acessar a aplicação.</p><p><strong>— </strong><a href="http://docs.azk.io/pt-BR/azkfilejs/envs.html"><strong>envs</strong></a><strong>: </strong>Incluimos as variaveis de ambiente `NODE_PORT`,`PORT` e `PATH` no contexto do sistema. A env PATH foi definida para que os módulos do node possam ser utilizados diretamente, dispensando a necessidade de digitar o caminho completo. Ex: `node_modules/.bin/grunt`.</p><h3>Inicialização</h3><p>Agora que o Azkfile.js está completo podemos iniciar a aplicação:</p><pre>$ azk start —-open</pre><p>O azk se responsabilizará por baixar a imagem do Docker, e sendo a primeira vez que o UMRUM será levantado em nossa maquina, o azk fará também o provisionamento baixando todas dependências (`npm install`) e a compilação do código (`grunt compile`).</p><p>A opção `—open` é uma opção que diz para o azk abrir a URL do projeto no navegador após levantar o projeto.</p><h3>Trabalhando com o azk</h3><p>Para que façamos um bom uso do azk, vamos anotar alguns comandos que serão importante enquanto trabalhamos.</p><ul><li><strong>shell:</strong> O commando <strong>`azk shell`</strong> irá abrir um shell para o container do UMRUM. Assim podemos executar comandos e/ou tarefas.</li></ul><pre># abre um shell iterativo para um container do UMRUM<br>$ azk shell</pre><pre># executa a task `grunt compile`<br>$ azk shell -c &#39;grunt compile&#39;</pre><h3>Observações</h3><h4>Provision</h4><p>Uma observação importante que devemos aprender, é separar bem os processos de provisionamento, compilação e inicialização.</p><p>O <strong>provision</strong> é o processo de preparação do ambiente, tais como, instalação das dependências e compilação do código.</p><p>A <strong>compilação</strong> no UMRUM acontece através de um &quot;Watch&quot; que fica identificando as alterações e compila quando necessário. Esse processo pode e deve ser executado de forma paralela, já que isso não está diretamente relacionado ao processo de incialização da aplicação.</p><pre># executa a task `grunt compile`<br>$ azk shell -c &#39;grunt compile&#39;</pre><p>A <strong>inicialização</strong> é feita pelo azk executando o comando definido em <strong>`command`</strong>. No caso do UMRUM foi utilizado o <a href="http://nodemon.io/">nodemon</a> para levantar a aplicação pois ele traz alguns benefícios (que não vem ao caso citarmos). A opção `<strong>wait.timeout`</strong> teve de ser alterada pois o nodemon tem um tempo de inicialização maior.</p><h4>.env</h4><p>Uma curiosidade sobre o azk é que ele tem suporte nativo ao `.env`. Quando o azk levanta alguma instância ou shell, ele automaticamente lê o arquivo `.env` e adiciona seu conteudo as variáveis de ambiente.</p><p>Para visualizar as variáveis de ambiente podemos executar o seguinte comando:</p><pre>$ azk shell -c &#39;env&#39;</pre><p>É estritamente recomendado que todas informações sensíveis (como credenciais de acesso) sejam armazenadas em um arquivo `.env` e que esse seja ignorado no git.</p><p>Para saber mais sobre o azk, acesse:</p><p><a href="https://github.com/azukiapp/azk">azukiapp/azk</a></p><p>Para saber mais ou como contribuir para o UMRUM basta seguir as instruções disponíveis no README do projeto no github:</p><p><a href="https://github.com/umrum/umrum">umrum/umrum</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0424389d9ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>