Quite frustrated to deploy my golang website.

agolangf · · 594 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have developed my blog website along with admin panel. Now I can not deploy it anywhere. Before I have used heroku for this, but now it gives me error. Google appengine also disappointed me. Would you please show me easy way to deploy this freaking app?</p> <hr/>**评论:**<br/><br/>Patchthesock: <pre><p>This is why I love programming, when shit goes wrong it&#39;s generally my own fault. Find and fix your errors, or at least give the people willing to help a clue.</p></pre>tural-esger: <pre><p>But it is not that hard to find solution with PHP. I am crazy about programming especially with Go. But when it comes to deployment, I can not find any solution to satisfy me. Still I am insisting on writing with Go.</p></pre>SeerUD: <pre><p>You&#39;re saying that because you&#39;re used to PHP - in reality, Go is far simpler to deploy than PHP is.</p></pre>francoishill: <pre><p>If you consider how many php hosting sites there are, it is much simpler that golang. Although I prefer golang, php is easier in that regard. But for golang deployment I prefer Docker.</p></pre>SeerUD: <pre><blockquote> <p>But for golang deployment I prefer Docker.</p> </blockquote> <p>Definitely agree here, it&#39;s super easy with Docker.</p> <blockquote> <p>If you consider how many php hosting sites there are</p> </blockquote> <p>I don&#39;t see how the amount of hosting sites makes it any easier. You&#39;re still dealing with lots of files, and being at the mercy of PHP&#39;s configuration on that host, if you&#39;re not setting it up yourself.</p> <p>At least with Go, it&#39;s just a dump and run kind of situation.</p></pre>Creshal: <pre><blockquote> <p>but now it gives me error</p> </blockquote> <p>Fix the errors.</p></pre>tural-esger: <pre><p>How worldly.</p></pre>El_Skippito: <pre><p>What did you expect when your OP can be summarized, with no loss of detail, as &#34;shit doesn&#39;t work?&#34; </p></pre>tural-esger: <pre><p>Paraphrase </p></pre>epiris: <pre><p>It&#39;s a single static binary, it has literally the least number of things that could possibly go wrong. You need to run an executable, that&#39;s it. Get a cheap vm from any company, Scp the damn binary to it, ssh to the server, ./Go-blog to run it. Done. Your issue isn&#39;t Go but the abstractions in front of it you don&#39;t understand. So remove them.</p></pre>tural-esger: <pre><p>I know it has nothing to do with Go, I run it in local environment pretty well. Have you ever deployed on vm? I mean what would you recommend?</p></pre>epiris: <pre><p>Yes, on lots. All you need is the binary and a systemd unit file for the service. Start by getting the blog up and running and if you get stuck making a systemd unit file ask me for help, I got copy pasta on my workstation I&#39;ll post for you.</p></pre>steffen25: <pre><p>Any chance you could post it here I would like to see it as well :) </p></pre>epiris: <pre><p>Sure, <a href="https://gist.github.com/cstockton/ac9a95f865607d2b5a2041ba5824eb94" rel="nofollow">here is a gist</a> that can serve as basic example for running a service on port 443 on bare metal.</p></pre>tural-esger: <pre><p>Man thank you for your help. I have never used vm or something. Tha is why I don&#39;t know where to start. Should I buy VPS?</p></pre>epiris: <pre><p>Well purchasing / budget decisions have to be purely your own. But I think it&#39;s a good learning experience if you have never done it before. I take it you run Windows as your main os? If so maybe download virtual box and the latest version of Ubuntu-server and test out a systemd service there first. There isn&#39;t much to it though, follow my gist in the other comment and just post here if you get stuck.</p></pre>tural-esger: <pre><p>Yes I use windows. I am aware of using Linux. I use it once in a while. Thank you very much for your support. I will do and tell you. </p></pre>tmpler: <pre><blockquote> <p>but now it gives me error</p> </blockquote> <p>which errors?</p></pre>tural-esger: <pre><p>Heroku error logs</p> <p>2017-07-03T10:38:04.090899+00:00 heroku[router]: at=error code=H10 desc=&#34;App crashed&#34; method=GET path=&#34;/&#34; host=turalasga r.herokuapp.com request_id=c063ee5a-4a73-451b-a1d7-3d1eb6b05bf7 fwd=&#34;185.43.191.172&#34; dyno= connect= service= status=503 bytes= protocol=https 2017-07-03T10:38:04.393113+00:00 heroku[router]: at=error code=H10 desc=&#34;App crashed&#34; method=GET path=&#34;/favicon.ico&#34; hos t=turalasgar.herokuapp.com request_id=7ea40084-38ad-4dc7-9b17-8036d7431e16 fwd=&#34;185.43.191.172&#34; dyno= connect= service= status=503 bytes= protocol=https 2017-07-03T10:38:09.007090+00:00 heroku[web.1]: State changed from crashed to starting 2017-07-03T10:38:10.423771+00:00 heroku[web.1]: Starting process with command go-blog 2017-07-03T10:38:12.360909+00:00 heroku[web.1]: State changed from starting to crashed 2017-07-03T10:38:12.353276+00:00 heroku[web.1]: Process exited with status 127 2017-07-03T10:38:12.277685+00:00 app[web.1]: bash: go-blog: command not found 2017-07-03T10:39:41.981551+00:00 heroku[web.1]: State changed from crashed to starting 2017-07-03T10:39:43.394609+00:00 heroku[web.1]: Starting process with command go-blog 2017-07-03T10:39:44.873576+00:00 heroku[web.1]: State changed from starting to crashed 2017-07-03T10:39:44.858043+00:00 heroku[web.1]: Process exited with status 127 2017-07-03T10:39:44.814585+00:00 app[web.1]: bash: go-blog: command not found</p></pre>itsamemmario: <pre><p>I&#39;ve never user Heroku, but ut seems as if your $PATH variable in bash doesn&#39;t contain the path to your go-blog binary.</p> <p>A quick google search shows that you need to put .profile.d file in your build directory and set the path in there</p> <p>Good luck </p></pre>tural-esger: <pre><p>Thank you very much for your support. But nope, no .profile.d is used here. I have deployed before and has been working until now. <a href="https://loginparol.herokuapp.com" rel="nofollow">https://loginparol.herokuapp.com</a>. But now for some reasons it doesn&#39;t work. Thank you.</p></pre>itsamemmario: <pre><p>What i&#39;m trying to say is, you should try and use a .profile.d to set up your envorinment var. The error message seems pretty clear to me.... heroku can&#39;t find you binary called go-blog</p> <p>so you have to define that varaible in your deployment.</p> <p>try this:</p> <pre><code>heroku run bash echo $PATH </code></pre> <p>is your executabe in any directory listed there? If so the error is different. Otherwise create that file and ensure you set the path variable.</p></pre>tural-esger: <pre><p>Which variables do you mean? The app shown above doesn&#39;t use any variable(provided by me).</p></pre>epiris: <pre><p>He means the environment, that is how your shell finds programs to run. When you type &#34;ls&#34; your shell checks PATH to find an executable named ls. Read <a href="https://en.m.wikipedia.org/wiki/PATH_(variable)#/editor/2" rel="nofollow">https://en.m.wikipedia.org/wiki/PATH_(variable)#/editor/2</a></p> <p>Because heroku.. has an abstraction in front of everything I can&#39;t say what it allows. But try an absolute path to your binary, if that fails try placing this in whatever their concept of a profile or exports is:</p> <pre><code>what_path_to_use=$(dirname /home/tesger/bin/go-blog) export PATH=&#34;${PATH}:${what_path..to use}&#34; </code></pre> <p>Assignment is for illustration, you just need to replace the second var with the surname that contains the binary.</p></pre>HelperBot_: <pre><p>Non-Mobile link: <a href="https://en.wikipedia.org/wiki/PATH_(variable)#/editor/2" rel="nofollow">https://en.wikipedia.org/wiki/PATH_(variable)#/editor/2</a></p> <hr/> <p><sup>HelperBot</sup> <sup>v1.1</sup> <sup><a href="/r/HelperBot_" rel="nofollow">/r/HelperBot_</a></sup> <sup>I</sup> <sup>am</sup> <sup>a</sup> <sup>bot.</sup> <sup>Please</sup> <sup>message</sup> <sup><a href="/u/swim1929" rel="nofollow">/u/swim1929</a></sup> <sup>with</sup> <sup>any</sup> <sup>feedback</sup> <sup>and/or</sup> <sup>hate.</sup> <sup>Counter:</sup> <sup>87104</sup></p></pre>rat9988: <pre><p>It doesn&#39;t matter that you didn&#39;t use them. Things like .profile and environment variables are still used by your go program and heroku&#39;s deployment tool.</p></pre>rwbcxrz: <pre><p>It&#39;s possible something is going wrong with the build process.</p> <p>I haven&#39;t used Go on Heroku for awhile, but if I recall correctly, the default Go buildpack expects your <code>main</code> package to be in the repository root. If your <code>main</code> is somewhere else, like <code>cmd/blog/main.go</code>, then that could potentially cause a problem similar to this.</p> <p>When I was deploying Go apps to Heroku, I found it was really helpful to read through the buildpack source so that I understood better what it was doing and what it expected. <a href="https://github.com/heroku/heroku-buildpack-go" rel="nofollow">https://github.com/heroku/heroku-buildpack-go</a></p></pre>kpurdon: <pre><p>Deploying on heroku is insanely simple, especially for go apps. <a href="https://devcenter.heroku.com/articles/getting-started-with-go#introduction" rel="nofollow">https://devcenter.heroku.com/articles/getting-started-with-go#introduction</a> ... the error you linked in comments indicates that somewhere your setup is incorrect. Can you link you code/configuration? Happy to help debug but need more information.</p></pre>

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

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