<?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[Coding and deploying in the cloud - Medium]]></title>
        <description><![CDATA[Interesting stuff about programming, programming languages, cloud technologies, deployment - Medium]]></description>
        <link>https://medium.com/coding-and-deploying-in-the-cloud?source=rss----ce3151655ea5---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Coding and deploying in the cloud - Medium</title>
            <link>https://medium.com/coding-and-deploying-in-the-cloud?source=rss----ce3151655ea5---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:49:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/coding-and-deploying-in-the-cloud" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Logging from CoreOS to Logentries]]></title>
            <link>https://medium.com/coding-and-deploying-in-the-cloud/logging-from-coreos-to-logentries-4da79e282725?source=rss----ce3151655ea5---4</link>
            <guid isPermaLink="false">https://medium.com/p/4da79e282725</guid>
            <dc:creator><![CDATA[Gal Ben-Haim]]></dc:creator>
            <pubDate>Tue, 30 Sep 2014 22:16:51 GMT</pubDate>
            <atom:updated>2014-09-30T22:48:40.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*y9GmhoC5Zd8lXIATQHK3Pw.png" /></figure><p>a new simple method to send log data from CoreOS nodes to Logentries</p><blockquote>Set the Logentries account key in etcdctl</blockquote><pre>etcdctl set /settings/global/le_account_key &lt;account_key&gt;</pre><blockquote>Register a new host and set the host key for the node’s ip addres in etcdctl</blockquote><pre>etcdctl set /le/`/bin/ifconfig eth0 | awk &#39;/inet /{print $2}&#39;` &lt;host_key&gt;</pre><blockquote>Mount the logs directory as a volume and follow some log files</blockquote><pre>docker run —rm -it -v /home/core/log:/data gbenhaim/le —account-key=&lt;account_key&gt; —host-key=&lt;host_key&gt; follow “/data/backend/*” —name “backend.log”</pre><blockquote>Write a fleet unit file and start the service</blockquote><pre>[Unit]<br>Description=Logentries logger<br>After=docker.service</pre><pre>[Service]<br>TimeoutStartSec=0<br>ExecStartPre=-/usr/bin/docker kill le<br>ExecStartPre=-/usr/bin/docker rm le<br>ExecStartPre=/usr/bin/docker pull gbenhaim/le<br>ExecStart=/usr/bin/bash -c \<br>“export HOST_IP=`/bin/ifconfig eth0 | awk ‘/inet /{print $2}’`; \<br>export HOST_KEY=`etcdctl get /le/$HOST_IP`; \<br>/usr/bin/docker run —privileged —name le -v /home/core/log:/data gbenhaim/le \<br>—account-key=`etcdctl get /settings/global/le_account_key` \<br>—host-key=$HOST_KEY \<br>monitor” <br>ExecStop=/usr/bin/docker stop le</pre><pre>[X-Fleet]<br>Global=true</pre><p>Setting Global=true will make the service run on all machines in the cluster,<br>if all of them have host keys set in etcdctl and are set to follow some logs the entire cluster will automagically send log data to Logentries.</p><p>One issue with this method is that network statistics that are reported to Logentries are incorrect, as the Docker container doesn’t have access to the actual network interface.</p><p>If its possible that the node ip will change (like on EC2), consider storing the host key in a local file instead of etcd. Make sure it has the same path on each one of the nodes in the cluster.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4da79e282725" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-and-deploying-in-the-cloud/logging-from-coreos-to-logentries-4da79e282725">Logging from CoreOS to Logentries</a> was originally published in <a href="https://medium.com/coding-and-deploying-in-the-cloud">Coding and deploying in the cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time stamps in Golang]]></title>
            <link>https://medium.com/coding-and-deploying-in-the-cloud/time-stamps-in-golang-abcaf581b72f?source=rss----ce3151655ea5---4</link>
            <guid isPermaLink="false">https://medium.com/p/abcaf581b72f</guid>
            <dc:creator><![CDATA[Gal Ben-Haim]]></dc:creator>
            <pubDate>Fri, 05 Sep 2014 08:56:43 GMT</pubDate>
            <atom:updated>2014-09-05T09:03:08.459Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*CKsVcG6icfjsmoeoSJUrPQ.png" /></figure><h3>UNIX time stamps in Golang</h3><p>How to use UNIX time stamps in a Golang web service</p><p>While building a RESTful JSON web service in Golang (which uses the awesome <a href="http://labix.org/v2/mgo">mgo</a> MongoDB client library) I wanted to use UNIX timestamps all over instead of RFC3339 or ISO dates and found the default behavior of both <a href="http://labix.org/v2/mgo">mgo</a> and <a href="http://golang.org/pkg/encoding/json/">encoding/json</a> of marshaling and unmarshaling <a href="http://golang.org/pkg/time/#Time">time.Time</a> objects kind of limiting.</p><p>Take the following User struct as an example:</p><pre>type User struct {<br>    Name string<br>    UpdatedAt time.Time `bson:&quot;updated_at,omitempty&quot; json:&quot;updated_at,omitempty&quot;<br>}</pre><p>The first problem here is with the “omitempty” tag, time.Time is never a zero value so it exists always (find zero value time.Time objects with the IsZero() function). The solution is to use a pointer instead of the actual object:</p><pre>type User struct {<br>    Name string<br>    UpdatedAt *time.Time `bson:&quot;updated_at,omitempty&quot; json:&quot;updated_at,omitempty&quot;<br>}</pre><p>In this case, whenever the UpdatedAt field is not set, the pointer is nil and encoding/json knows that it should omit it.</p><p>Next thing is that time.Time is marshaled and unmarshaled to/from RFC3339 date, let’s define a new type:</p><pre>type Timestamp time.Time</pre><pre>func (t *Timestamp) MarshalJSON() ([]byte, error) {<br>    ts := time.Time(*t).Unix()<br>    stamp := fmt.Sprint(ts)</pre><pre>    return []byte(stamp), nil<br>}</pre><pre>func (t *Timestamp) UnmarshalJSON(b []byte) error {<br>    ts, err := strconv.Atoi(string(b))<br>    if err != nil {<br>        return err<br>    }</pre><pre>    *t = Timestamp(time.Unix(int64(ts), 0))</pre><pre>    return nil<br>}</pre><p>And change our initial struct:</p><pre>type User struct {<br>    Name string<br>    UpdatedAt *Timestamp `bson:&quot;updated_at,omitempty&quot; json:&quot;updated_at,omitempty&quot;<br>}</pre><p>So what’s happening here is that we defined how encoding/json marshals and unmarshals the Timestamp object, which basically return a string of the UNIX time when marshaling and return a new Timestamp object from an int64 timestamp when unmarshaling.</p><p>Only problem left is that mgo doesn’t know how to marshal and unmarshal the Timestamp object. We can do allmost the same by implementing the <a href="http://godoc.org/labix.org/v2/mgo/bson#Setter">Setter </a>and <a href="http://godoc.org/labix.org/v2/mgo/bson#Getter">Getter</a> interfaces.</p><p>The result:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f9a482ebd2753e5d7f41c1c6d67301c/href">https://medium.com/media/3f9a482ebd2753e5d7f41c1c6d67301c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abcaf581b72f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-and-deploying-in-the-cloud/time-stamps-in-golang-abcaf581b72f">Time stamps in Golang</a> was originally published in <a href="https://medium.com/coding-and-deploying-in-the-cloud">Coding and deploying in the cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to catch exceptions raised by Python worker threads]]></title>
            <link>https://medium.com/coding-and-deploying-in-the-cloud/how-to-catch-exceptions-raised-by-python-worker-threads-313a2cbda8f?source=rss----ce3151655ea5---4</link>
            <guid isPermaLink="false">https://medium.com/p/313a2cbda8f</guid>
            <dc:creator><![CDATA[Gal Ben-Haim]]></dc:creator>
            <pubDate>Sun, 29 Jun 2014 05:46:36 GMT</pubDate>
            <atom:updated>2014-06-29T05:46:36.774Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes its necessary to catch exceptions that are raised by Python worker threads, this can be done as following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdec765416a61c2c9cc26d3e531256c4/href">https://medium.com/media/cdec765416a61c2c9cc26d3e531256c4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=313a2cbda8f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-and-deploying-in-the-cloud/how-to-catch-exceptions-raised-by-python-worker-threads-313a2cbda8f">How to catch exceptions raised by Python worker threads</a> was originally published in <a href="https://medium.com/coding-and-deploying-in-the-cloud">Coding and deploying in the cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple logging to Logentries from a Docker container]]></title>
            <link>https://medium.com/coding-and-deploying-in-the-cloud/simple-logging-to-logentries-from-a-docker-container-d3609073db30?source=rss----ce3151655ea5---4</link>
            <guid isPermaLink="false">https://medium.com/p/d3609073db30</guid>
            <dc:creator><![CDATA[Gal Ben-Haim]]></dc:creator>
            <pubDate>Sat, 28 Jun 2014 22:51:25 GMT</pubDate>
            <atom:updated>2014-06-28T22:46:58.131Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMTF48jR5g8UNAj6W_MOgw.jpeg" /></figure><h4>Simple solution for centralized logging from inside Docker containers that run supervisord</h4><p>While building <a href="http://docker.io/">Docker</a> images for a production deployment I encountered a problem with proper logging of what’s going on inside the containers, especially if using <a href="http://supervisord.org/">supervisord</a> to run multiple processes.</p><p>One simple solution can be to share the /var/log/supervisor directory with the host.</p><p>Since I’m already using <a href="http://logentries.com/">Logentries</a> for centralized logging solution and I’ve already written a <a href="https://github.com/bsphere/le_go">Golang client lib for it</a>, I decided to use it for a simple log dump solution that can be used from inside a Docker container — <a href="https://github.com/bsphere/lecat">https://github.com/bsphere/lecat</a></p><p>All there is left to do is create a new Logentries token and change the stdout change the random log file names of supervisord child processes to known path as described in <a href="http://supervisord.org/configuration.html">http://supervisord.org/configuration.html</a>.</p><p>Then, add additional supervisord child processes such as</p><pre>[program:log_nginx]<br>command=tail -F /var/log/nginx/access.log | lecat -token &lt;logentries_token&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3609073db30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-and-deploying-in-the-cloud/simple-logging-to-logentries-from-a-docker-container-d3609073db30">Simple logging to Logentries from a Docker container</a> was originally published in <a href="https://medium.com/coding-and-deploying-in-the-cloud">Coding and deploying in the cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>