英文:
Google App Engine custom IP port in Go
问题
我想在GAE上用Go创建一个Web应用程序,并且我需要它监听一个自定义端口。我该如何设置它?我尝试在沙盒中使用http.ListenAndServe(":12345", nil),但在控制台中得到了以下信息:
警告 2011-10-07 20:01:01,252 urlfetch_stub.py:108] 找不到ssl包。urlfetch将无法验证SSL证书。
信息 2011-10-07 20:01:01,847 appengine_rpc.py:159] 服务器:appengine.google.com
信息 2011-10-07 20:01:01,855 appcfg.py:463] 检查SDK的更新。
信息 2011-10-07 20:01:04,625 appcfg.py:480] SDK已经是最新版本。
警告 2011-10-07 20:01:04,625 datastore_file_stub.py:512] 无法从/var/folders/e0/e0U5NtMXFHOB6jVwkVhsnE+++TM/-Tmp-/dev_appserver.datastore读取数据存储。
信息 2011-10-07 20:01:04,627 rdbms_sqlite.py:58] 连接到SQLite数据库'',文件为'/var/folders/e0/e0U5NtMXFHOB6jVwkVhsnE+++TM/-Tmp-/dev_appserver.rdbms'
警告 2011-10-07 20:01:04,633 dev_appserver.py:4748] 无法初始化图像API;您可能缺少Python的“PIL”模块。导入错误:找不到模块名为_imaging
信息 2011-10-07 20:01:04,641 dev_appserver_multiprocess.py:637] 在端口8080上运行应用程序tpbitblock:http://localhost:8080
信息 2011-10-07 20:01:08,448 __init__.py:365] 构建_go_app
信息 2011-10-07 20:01:11,105 __init__.py:351] 运行_go_app
抛出:初始化重新调度
runtime.throw+0x40 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/runtime.c:102
runtime.throw(0x278c7f, 0xdc73)
schedule+0x3e /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:535
schedule(0x10803000, 0x10803000)
runtime.mcall+0x3a /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:174
runtime.mcall(0x10803000, 0x0)
协程2 [1]:
net.*pollServer∑Run /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:213
net.*pollServer∑Run(0x10801c90, 0x0)
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- 由以下代码创建的协程 -----
net.newPollServer+0x2dd /private/tmp/appengine/google_appengine/goroot/src/pkg/net/newpollserver.go:39
协程1 [4]:
runtime.gosched+0x4d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:603
runtime.gosched()
runtime.chanrecv+0x14d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:361
runtime.chanrecv(0x1081d900, 0x30800e6c, 0x0, 0x0, 0x0, ...)
runtime.chanrecv1+0x3f /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:424
runtime.chanrecv1(0x1081d900, 0x1081e580)
net.*pollServer∑WaitRead+0x47 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:255
net.*pollServer∑WaitRead(0x10801c90, 0x1081e580, 0x0)
net.*netFD∑accept+0x2ae /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:605
net.*netFD∑accept(0x1081e580, 0x45716, 0x0, 0x0, 0x0, ...)
net.*TCPListener∑AcceptTCP+0x53 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:272
net.*TCPListener∑AcceptTCP(0x108008b8, 0x30800f00, 0x0, 0x0)
net.*TCPListener∑Accept+0x36 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:282
net.*TCPListener∑Accept(0x108008b8, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server∑Serve+0x96 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:868
http.*Server∑Serve(0x10839d20, 0x10839e20, 0x108008b8, 0x0, 0x0, ...)
http.*Server∑ListenAndServe+0x9c /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:855
http.*Server∑ListenAndServe(0x10839d20, 0x10839d20, 0x406)
http.ListenAndServe+0x52 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:920
http.ListenAndServe(0x155640, 0x6, 0x0, 0x0, 0x0, ...)
BitBlock.init∑1+0x174 BitBlock/BitBlock.go:43
BitBlock.init∑1()
BitBlock.init+0x70 BitBlock/BitBlock.go:0
BitBlock.init()
main.init+0x39 _go_main.go:0
main.init()
runtime.mainstart+0x5 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:91
runtime.mainstart()
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- 由以下代码创建的协程 -----
_rt0_386+0xbf /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:80
错误 2011-10-07 20:01:12,196 dev_appserver.py:4200] 处理请求时遇到异常
追踪最近的调用(最近的调用在最上面):
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第4143行,函数_HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第4049行,函数_Dispatch
base_env_dict=env_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第616行,函数Dispatch
base_env_dict=base_env_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第3120行,函数Dispatch
self._module_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第2972行,函数ExecuteCGI
env, infile, outfile)
文件“/Google App Engine/google/appengine/ext/go/__init__.py”,第399行,函数execute_go_cgi
GO_APP.make_and_run()
文件“/Google App Engine/google/appengine/ext/go/__init__.py”,第362行,函数make_and_run
wait_until_go_app_ready(self.proc.pid)
文件“/Google App Engine/google/appengine/ext/go/__init__.py”,第285行,函数wait_until_go_app_ready
raise Exception('无法启动' + GO_APP_NAME)
异常:无法启动_go_app
信息 2011-10-07 20:01:12,242 dev_appserver.py:4247] “GET / HTTP/1.1” 500 -
信息 2011-10-07 20:01:12,505 __init__.py:351] 运行_go_app
抛出:初始化重新调度
runtime.throw+0x40 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/runtime.c:102
runtime.throw(0x278c7f, 0xdc73)
schedule+0x3e /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:535
schedule(0x10803000, 0x10803000)
runtime.mcall+0x3a /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:174
runtime.mcall(0x10803000, 0x0)
协程2 [1]:
net.*pollServer∑Run /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:213
net.*pollServer∑Run(0x10801c90, 0x0)
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- 由以下代码创建的协程 -----
net.newPollServer+0x2dd /private/tmp/appengine/google_appengine/goroot/src/pkg/net/newpollserver.go:39
协程1 [4]:
runtime.gosched+0x4d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:603
runtime.gosched()
runtime.chanrecv+0x14d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:361
runtime.chanrecv(0x1081d900, 0x30800e6c, 0x0, 0x0, 0x0, ...)
runtime.chanrecv1+0x3f /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:424
runtime.chanrecv1(0x1081d900, 0x1081e580)
net.*pollServer∑WaitRead+0x47 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:255
net.*pollServer∑WaitRead(0x10801c90, 0x1081e580, 0x0)
net.*netFD∑accept+0x2ae /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:605
net.*netFD∑accept(0x1081e580, 0x45716, 0x0, 0x0, 0x0, ...)
net.*TCPListener∑AcceptTCP+0x53 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:272
net.*TCPListener∑AcceptTCP(0x108008b8, 0x30800f00, 0x0, 0x0)
net.*TCPListener∑Accept+0x36 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:282
net.*TCPListener∑Accept(0x108008b8, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server∑Serve+0x96 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:868
http.*Server∑Serve(0x10839d20, 0x10839e20, 0x108008b8, 0x0, 0x0, ...)
http.*Server∑ListenAndServe+0x9c /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:855
http.*Server∑ListenAndServe(0x10839d20, 0x10839d20, 0x406)
http.ListenAndServe+0x52 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:920
http.ListenAndServe(0x155640, 0x6, 0x0, 0x0, 0x0, ...)
BitBlock.init∑1+0x174 BitBlock/BitBlock.go:43
BitBlock.init∑1()
BitBlock.init+0x70 BitBlock/BitBlock.go:0
BitBlock.init()
main.init+0x39 _go_main.go:0
main.init()
runtime.mainstart+0x5 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:91
runtime.mainstart()
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- 由以下代码创建的协程 -----
_rt0_386+0xbf /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:80
错误 2011-10-07 20:01:13,530 dev_appserver.py:4200] 处理请求时遇到异常
追踪最近的调用(最近的调用在最上面):
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第4143行,函数_HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第4049行,函数_Dispatch
base_env_dict=env_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第616行,函数Dispatch
base_env_dict=base_env_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第3120行,函数Dispatch
self._module_dict)
文件“/Google App Engine/google/appengine/tools/dev_appserver.py”,第2972行,函数ExecuteCGI
env, infile, outfile)
文件“/Google App Engine/google/appengine/ext/go/__init__.py”,第399行,函数execute_go_cgi
GO_APP.make_and_run()
文件“/Google App Engine/google/appengine/ext/go/__init__.py”,第362行,函数make_and_run
wait_until_go_app_ready(self.proc.pid)
文件“/Google App Engine/google/appengine/ext/go/__init__.py”,第285行,函数wait_until_go_app_ready
raise Exception('无法启动' + GO_APP_NAME)
异常:无法启动_go_app
信息 2011-10-07 20:01:13,531 dev_appserver.py:4247] “GET /favicon.ico HTTP/1.1” 500 -
英文:
I want to create a web app on GAE in Go and I need it to listen to a custom port. How do I set it up? I tried to use http.ListenAndServe(":12345", nil) in the sandbox, but got this in my console:
WARNING 2011-10-07 20:01:01,252 urlfetch_stub.py:108] No ssl package found. urlfetch
will not be able to validate SSL certificates.
INFO 2011-10-07 20:01:01,847 appengine_rpc.py:159] Server: appengine.google.com
INFO 2011-10-07 20:01:01,855 appcfg.py:463] Checking for updates to the SDK.
INFO 2011-10-07 20:01:04,625 appcfg.py:480] The SDK is up to date.
WARNING 2011-10-07 20:01:04,625 datastore_file_stub.py:512] Could not read datastore data from /var/folders/e0/e0U5NtMXFHOB6jVwkVhsnE+++TM/-Tmp-/dev_appserver.datastore
INFO 2011-10-07 20:01:04,627 rdbms_sqlite.py:58] Connecting to SQLite database '' with file '/var/folders/e0/e0U5NtMXFHOB6jVwkVhsnE+++TM/-Tmp-/dev_appserver.rdbms'
WARNING 2011-10-07 20:01:04,633 dev_appserver.py:4748] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO 2011-10-07 20:01:04,641 dev_appserver_multiprocess.py:637] Running application tpbitblock on port 8080: http://localhost:8080
INFO 2011-10-07 20:01:08,448 __init__.py:365] building _go_app
INFO 2011-10-07 20:01:11,105 __init__.py:351] running _go_app
throw: init rescheduling
runtime.throw+0x40 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/runtime.c:102
runtime.throw(0x278c7f, 0xdc73)
schedule+0x3e /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:535
schedule(0x10803000, 0x10803000)
runtime.mcall+0x3a /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:174
runtime.mcall(0x10803000, 0x0)
goroutine 2 [1]:
net.*pollServer·Run /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:213
net.*pollServer·Run(0x10801c90, 0x0)
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
net.newPollServer+0x2dd /private/tmp/appengine/google_appengine/goroot/src/pkg/net/newpollserver.go:39
goroutine 1 [4]:
runtime.gosched+0x4d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:603
runtime.gosched()
runtime.chanrecv+0x14d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:361
runtime.chanrecv(0x1081d900, 0x30800e6c, 0x0, 0x0, 0x0, ...)
runtime.chanrecv1+0x3f /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:424
runtime.chanrecv1(0x1081d900, 0x1081e580)
net.*pollServer·WaitRead+0x47 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x10801c90, 0x1081e580, 0x0)
net.*netFD·accept+0x2ae /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:605
net.*netFD·accept(0x1081e580, 0x45716, 0x0, 0x0, 0x0, ...)
net.*TCPListener·AcceptTCP+0x53 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:272
net.*TCPListener·AcceptTCP(0x108008b8, 0x30800f00, 0x0, 0x0)
net.*TCPListener·Accept+0x36 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:282
net.*TCPListener·Accept(0x108008b8, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server·Serve+0x96 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:868
http.*Server·Serve(0x10839d20, 0x10839e20, 0x108008b8, 0x0, 0x0, ...)
http.*Server·ListenAndServe+0x9c /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:855
http.*Server·ListenAndServe(0x10839d20, 0x10839d20, 0x406)
http.ListenAndServe+0x52 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:920
http.ListenAndServe(0x155640, 0x6, 0x0, 0x0, 0x0, ...)
BitBlock.init·1+0x174 BitBlock/BitBlock.go:43
BitBlock.init·1()
BitBlock.init+0x70 BitBlock/BitBlock.go:0
BitBlock.init()
main.init+0x39 _go_main.go:0
main.init()
runtime.mainstart+0x5 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:91
runtime.mainstart()
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xbf /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:80
ERROR 2011-10-07 20:01:12,196 dev_appserver.py:4200] Exception encountered handling request
Traceback (most recent call last):
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4143, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4049, in _Dispatch
base_env_dict=env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 616, in Dispatch
base_env_dict=base_env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 3120, in Dispatch
self._module_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 2972, in ExecuteCGI
env, infile, outfile)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 399, in execute_go_cgi
GO_APP.make_and_run()
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 362, in make_and_run
wait_until_go_app_ready(self.proc.pid)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 285, in wait_until_go_app_ready
raise Exception('unable to start ' + GO_APP_NAME)
Exception: unable to start _go_app
INFO 2011-10-07 20:01:12,242 dev_appserver.py:4247] "GET / HTTP/1.1" 500 -
INFO 2011-10-07 20:01:12,505 __init__.py:351] running _go_app
throw: init rescheduling
runtime.throw+0x40 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/runtime.c:102
runtime.throw(0x278c7f, 0xdc73)
schedule+0x3e /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:535
schedule(0x10803000, 0x10803000)
runtime.mcall+0x3a /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:174
runtime.mcall(0x10803000, 0x0)
goroutine 2 [1]:
net.*pollServer·Run /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:213
net.*pollServer·Run(0x10801c90, 0x0)
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
net.newPollServer+0x2dd /private/tmp/appengine/google_appengine/goroot/src/pkg/net/newpollserver.go:39
goroutine 1 [4]:
runtime.gosched+0x4d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:603
runtime.gosched()
runtime.chanrecv+0x14d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:361
runtime.chanrecv(0x1081d900, 0x30800e6c, 0x0, 0x0, 0x0, ...)
runtime.chanrecv1+0x3f /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:424
runtime.chanrecv1(0x1081d900, 0x1081e580)
net.*pollServer·WaitRead+0x47 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x10801c90, 0x1081e580, 0x0)
net.*netFD·accept+0x2ae /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:605
net.*netFD·accept(0x1081e580, 0x45716, 0x0, 0x0, 0x0, ...)
net.*TCPListener·AcceptTCP+0x53 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:272
net.*TCPListener·AcceptTCP(0x108008b8, 0x30800f00, 0x0, 0x0)
net.*TCPListener·Accept+0x36 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:282
net.*TCPListener·Accept(0x108008b8, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server·Serve+0x96 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:868
http.*Server·Serve(0x10839d20, 0x10839e20, 0x108008b8, 0x0, 0x0, ...)
http.*Server·ListenAndServe+0x9c /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:855
http.*Server·ListenAndServe(0x10839d20, 0x10839d20, 0x406)
http.ListenAndServe+0x52 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:920
http.ListenAndServe(0x155640, 0x6, 0x0, 0x0, 0x0, ...)
BitBlock.init·1+0x174 BitBlock/BitBlock.go:43
BitBlock.init·1()
BitBlock.init+0x70 BitBlock/BitBlock.go:0
BitBlock.init()
main.init+0x39 _go_main.go:0
main.init()
runtime.mainstart+0x5 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:91
runtime.mainstart()
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xbf /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:80
ERROR 2011-10-07 20:01:13,530 dev_appserver.py:4200] Exception encountered handling request
Traceback (most recent call last):
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4143, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4049, in _Dispatch
base_env_dict=env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 616, in Dispatch
base_env_dict=base_env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 3120, in Dispatch
self._module_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 2972, in ExecuteCGI
env, infile, outfile)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 399, in execute_go_cgi
GO_APP.make_and_run()
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 362, in make_and_run
wait_until_go_app_ready(self.proc.pid)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 285, in wait_until_go_app_ready
raise Exception('unable to start ' + GO_APP_NAME)
Exception: unable to start _go_app
INFO 2011-10-07 20:01:13,531 dev_appserver.py:4247] "GET /favicon.ico HTTP/1.1" 500 -
答案1
得分: 3
你不能这样做。App Engine不允许自定义的http端口。App Engine环境受到严格的沙箱限制,不是所有在纯Go(或Java或Python)中可以做的事情都可以在相应的App Engine环境中实现。
根据http://code.google.com/appengine/docs/go/overview.html:
与Java和Python环境一样,标准库的功能在沙箱内并不完全可用。例如,尝试打开套接字或写入文件将返回os.EINVAL错误。
Go应用程序在一个安全的“沙箱”环境中运行,具有一组减少的库。例如,应用程序不能将数据写入本地文件系统或进行任意网络连接。相反,应用程序使用由App Engine提供的可扩展服务来存储数据和通过互联网进行通信。
英文:
You can't do that. App Engine doesn't allow custom http ports. App Engine environment is heavily sandboxed and not everything that you can do in pure Go (or Java or Python) is available in their respective App Engine environments.
From http://code.google.com/appengine/docs/go/overview.html:
> As with the Java and Python environments, not all the standard library's functionality is available inside the sandbox. For example, attempts to open a socket or write to a file will return an os.EINVAL error.
>
> Go apps run inside a secure "sandbox" environment with a reduced set of libraries. For instance, an app cannot write data to the local file system or make arbitrary network connections. Instead, apps use scalable services provided by App Engine to store data and communicate over the Internet.
答案2
得分: 0
确实是可能的,你只需要执行goapp serve --port=3000
(或者你想要的任意端口)。
如果你正在尝试在虚拟机(如parallels)上访问你的goapp,你可以执行goapp serve --host=0.0.0.0
文档:https://cloud.google.com/appengine/docs/go/tools/devserver#Go_Command-line_arguments
英文:
It is indeed possible, all you need to do is goapp serve --port=3000
(or whatever port you'd like).
If you're trying to access your goapp on a VM (parallels), like I was, you can do goapp serve --host=0.0.0.0
Documentation: https://cloud.google.com/appengine/docs/go/tools/devserver#Go_Command-line_arguments
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论