Build code in cmd directory for app engine deploy?

agolangf · · 541 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have a webapp where the structure of different applications are in different cmd directories, for example:</p> <p>/cmd/frontend/main.go /cmd/manager/main.go /cmd/janitor/main.go</p> <p>which allows me to share a single codebase and have different services so I can do individual deployments.</p> <p>On Heroku when I do a deploy to the frontend I have the following set:</p> <pre><code>&#34;heroku&#34;: { &#34;goVersion&#34;: &#34;go1.9&#34;, &#34;install&#34;: [ &#34;./cmd/...&#34; ] }, </code></pre> <p>and then in the Procfile I can run the following:</p> <pre><code>web: frontend </code></pre> <p>Then it knows to run the &#39;frontend&#39; application.</p> <p>Is there a way I can do that with Google App Engine? Whether it be flex or standard?</p> <p>Currently when I try to deploy it complains because:</p> <pre><code>the root of your app needs to be package &#39;main&#39; </code></pre> <p>and there is no package main in the root since all of those are in their respective cmd directories.</p> <p>Has anyone ran into this issue? I&#39;ve been able to figure out how to make it work for heroku and AWS elastic beanstalk, but not google app engine.</p> <hr/>**评论:**<br/><br/>softwaregav: <pre><p>Excuse me if my answer is outdated, as I haven&#39;t used App Engine in over a year. You can actually put the package anywhere you&#39;d like. I usually put it in /appengine/. You then want the first line of <code>app.go</code> to be <code>// +build appengine</code> and declare this as <code>package main</code>. You can then wire everything up in <code>main()</code>, and don&#39;t forget to call <code>appengine.Main()</code> from the <code>google.golang.org/appengine</code> package. To get App Engine to use the file, you&#39;ll need an <code>app.yaml</code>, which should look something like:</p> <pre><code>service: test-service runtime: go api_version: &#39;go1.9&#39; - url: /.* script: _app_go </code></pre> <p>The <code>url</code> section basically tells App Engine to pass all routing over to your router, which is handled in <code>app.go</code>.</p></pre>

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

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