<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>"heroku": {
"goVersion": "go1.9",
"install": [
"./cmd/..."
]
},
</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 'frontend' 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 'main'
</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'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't used App Engine in over a year. You can actually put the package anywhere you'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'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'll need an <code>app.yaml</code>, which should look something like:</p>
<pre><code>service: test-service
runtime: go
api_version: 'go1.9'
- 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
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传