How to deploy your first Go web app

blov · · 1199 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><a href="http://www.vincepergolizzi.com/How-to-deploy-your-first-Go-web-app">http://www.vincepergolizzi.com/How-to-deploy-your-first-Go-web-app</a></p> <p>Would appreciate some feedback on this, I&#39;m quite new to Go and a lot of the stuff I wrote about so feel free to correct me or provide some suggestions on how to make the guide better.</p> <hr/>**评论:**<br/><br/>1Gijs: <pre><p>If you want to keep it simple, why add the nginx webserver ? Add the reason(s) why you think its good to do.</p> <p>Also, I think by default a Digital Ocean Ubuntu 14.04 distro has no firewall enabled ? In which case at least a link to this would be good to add: <a href="https://www.digitalocean.com/community/tutorials/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server">https://www.digitalocean.com/community/tutorials/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server</a></p> <p>Finally I think some specific link to setting up ssh keys would be recommendable as well.</p></pre>v89_cs: <pre><p>Thanks I added why to use nginx, and a small section on using ufw at the end.</p> <p>Good point about the SSH, I think I will write a paragraph or two about how to setup a deploy script so you can quickly push changes from dev to the server and that will require SSH setup to be explained.</p></pre>keithy12: <pre><p>nginx is pretty good to learn, it&#39;s good for newbies to learn how to set up subdomains for their projects.</p></pre>bankslain: <pre><blockquote> <p>./demo_webapp &amp;</p> </blockquote> <p>If you&#39;re exposing your project to the internet you probably at least want your app to auto-restart when it crashes or when the server reboots. Also, it might be an idea to run it as nobody instead of with your usual user account.</p></pre>v89_cs: <pre><p>Thanks, I actually don&#39;t know how to do this but I will investigate and add to the guide once I know how to do it and how to explain it.</p></pre>elithrar_: <pre><p>See here: <a href="http://elithrar.github.io/article/running-go-applications-in-the-background/">http://elithrar.github.io/article/running-go-applications-in-the-background/</a></p> <p>Supervisord is one way to do it, as it Upstart (someone provided an example) or systemd. I prefer Supervisor as it&#39;s cross-platform/portable across OS versions (hey, Debian!).</p></pre>dwevlo: <pre><p>You need to create an upstart script. For example: (in /etc/init/demo-webapp.conf)</p> <pre><code>description &#34;demo-webapp&#34; start on (started networking) respawn chdir /home/apps exec /home/apps/demo-webapp </code></pre> <p>Then <code>sudo initctl start demo-webapp</code>.</p> <p>Also most web apps have extra files, so I would rsync a whole folder over (the binary and any static js, css, images, etc)</p></pre>v89_cs: <pre><p>Thanks I will check this out, if you want I can credit you for this in the guide, PM me if you care about that.</p> <p>Yes Im going to expand on the rsync, and explain how to create a deploy scripts to push changes easily to the server.</p></pre>v89_cs: <pre><p>I&#39;ve added this now after testing it and credited you in the paragraph, thanks!</p></pre>010a: <pre><p>Its worth noting that choosing upstart for this part might not be such a good idea. Upstart is being replaced by systemd in ubuntu 15.04 (literally days from being released). It&#39;ll still be in 14.04 LTS until 16.04 comes out a year from now, but it might be worthwhile to include instructions for systemd as well.</p></pre>faendriel: <pre><p>what exactly is the benefit of nginx? can&#39;t I just SNAT to port 3000 from 80?</p></pre>q1t: <pre><p>it also handles https for all your apps on the server and deals with caching, and could work as a load balancer. That why I would prefer some kind of proxy server between my web apps and the wild. haproxy is another good alternative.</p></pre>v89_cs: <pre><p>I don&#39;t know, my intention is to have multiple apps on 1 server so I can hit a subdomain on port 80 and it will route to a specific Go app running on port Y</p> <p>If I go to the main domain it will go to another app and so on</p> <p>I then don&#39;t have to bog down any of my individual apps with this routing logic and can let nginx handle it all</p></pre>AnAge_OldProb: <pre><p>It&#39;s also a lot faster at serving static assets if you need to gain some performance there.</p></pre>warmans: <pre><p>You really need to package your application rather than manually creating all the scripts on the live server.</p> <p>There are various projects that make it easier to build all the package types from a single spec. Effing-package-manager is a popular one.</p> <p>Even if you don&#39;t actually package it as a deb or rpm you should still be able to install from source using a makefile or similar. It&#39;s pretty easy to do. Here is an example: <a href="https://github.com/warmans/fluentd-monitor/blob/master/Makefile#L17" rel="nofollow">https://github.com/warmans/fluentd-monitor/blob/master/Makefile#L17</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1199 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传