英文:
Go Revel framework port 9000 already in use
问题
我正在按照Go Revel框架的教程进行操作,一切都进行得很顺利,直到我运行测试应用程序时出现了以下错误:
$ revel run myapp
这个命令给出了正确的输出,但同时也出现了以下错误信息:
ERROR 2013/09/30 19:51:41 harness.go:167: Failed to start reverse proxy: listen tcp
<nil>:9000: address already in use
当我运行以下命令时:
$ sudo lsof -n -i4TCP:9000 | grep LISTEN
我得到了以下结果:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 11007 root 11u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11008 _www 0u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11009 _www 0u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11010 _www 0u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
我有一个在端口80上运行的PHP-NGINX应用程序,我不想关闭它,但我不知道这是否意味着这个PHP应用程序阻止了我的Go应用程序运行。
有人可以给予帮助吗?
我正在运行的是MacOS X 10.7.5。
英文:
I'm following along with the Go Revel framework nicely until I go to run the test app:
$ revel run myapp
which gives me the all the correct output but also gives the following error:
ERROR 2013/09/30 19:51:41 harness.go:167: Failed to start reverse proxy: listen tcp
<nil>:9000: address already in use
When I run this:
$ sudo lsof -n -i4TCP:9000 | grep LISTEN
I get this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 11007 root 11u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11008 _www 0u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11009 _www 0u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 11010 _www 0u IPv4 0xffffff801441dde0 0t0 TCP localhost:cslistener (LISTEN)
I have a PHP-NGINX app running on port 80 and don't want to lose that but have no idea whether this means this PHP app is blocking my Go app from running.
Can anyone chime in?
I'm running on MacOS X 10.7.5.
答案1
得分: 2
你可以通过以下两种方式更改 Revel 应用程序的端口:
-
编辑
config/app.conf
文件,并设置http.port = 8888
-
在运行 Revel 应用程序时,使用参数指定端口。你还需要指定
dev
或prod
来指定你的环境:revel run myapp dev 8888
英文:
You can change the port of a revel application with either:
-
Editing the
config/app.conf
file and settinghttp.port = 8888
-
Running your revel application with a parameter specifying the port. You'll also need to specify either
dev
orprod
to state your environment:revel run myapp dev 8888
答案2
得分: 1
建议使用lsof命令来检查是否已经有进程在该端口上运行:
lsof -i :9000
有时候,你会发现系统上没有安装lsof,那么首先需要安装lsof:
sudo apt-get install lsof
如果同一个应用程序在该端口上运行,你应该终止该进程并重新启动:
kill -9 PORT
如果该端口上有其他进程在运行,则建议按照@Vanessa的建议更改默认端口。
英文:
It's recommended to check out process is already running on this port by using lsof:
lsof -i :9000
Sometime, you see lsof is not installed on your system then first install lsof:
sudo apt-get install lsof
If same application running on this port, you should kill process and start again:
kill -9 PORT
In case some other process is running on this port then you should change default port as suggested by @Vanessa
答案3
得分: 0
你也可以尝试运行以下命令来查找并结束正在运行的revel应用程序:
ps -A | grep revel
如果找到正在运行的应用程序,你可以使用以下命令结束它:
kill PID
请将"PID"替换为实际的进程ID。
英文:
You may also try to run
ps -A | grep revel
It is possible that your revel app is still running. If it is, you can kill it with
kill PID
答案4
得分: 0
看起来你正在运行Nginx / PHP FPM,它将使用端口9000进行FPM进程通信。
你可以在PHP-FPM配置中更改这个端口,或者使用本地套接字(最好的选择),如果Nginx和php安装在同一台机器上的话。但是请确保更新Nginx站点定义以反映这个更改。
对于PHP,搜索php-fpm.conf文件中的listen指令:
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
在Nginx中更新fastcgi_pass指令:
fastcgi_pass 127.0.0.1:9000;
重新启动Nginx和PHP-FPM,然后你应该能够再次绑定到端口9000。
英文:
It looks like you're running Nginx / PHP FPM which will use port 9000 for the FPM process communication.
You can change this in your PHP-FPM configuration to either a different port or to use a local socket (preferable) if both Nginx and the php install are on the same machine) but be sure to update your Nginx site definitions to reflect this change as well.
For PHP search your php-fpm.conf for the listen directive:
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
And in Nginx update the fastcgi_pass directive:
fastcgi_pass 127.0.0.1:9000;
Restart both Nginx and PHP-FPM and you should be able to bind to port 9000 again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论