-
Notifications
You must be signed in to change notification settings - Fork 0
端口冲突的解决方案
778477 edited this page Mar 20, 2017
·
2 revisions
dumplings 应用原来指定的监听端口为 7001.
在实际生产环境中,我们发现有存在端口冲突的问题。
所以,在启动应用时应使用PORT=your_port_number node index.js
启动应用,其中your_port_number
指的就是未被占用的端口。在Thera
中,我们是通过下面的脚本扫描7000-65535号段的端口
#===============================================
# Copyright (C) 2017 All rights reserved.
#===============================================
# Filename: Find Unuse Port.sh
# Author: miaoyou.gmy
# Date: 2017-03-03
# Description:
# TCP 端口号是16位无符号整数,最大为 65535
# 该脚本指在 寻找(7000 - 65535)号段中未被使用的端口号
#
# Modification:
# V1. (7000 - 65535) 号段寻找未被使用的最小端口号
#===============================================
#!/bin/bash
endPortNumber=65535
starPortNumber=7000
for i in `seq $starPortNumber $endPortNumber`
do
`lsof -i:$i`
if [ `echo $?` -eq 1 ]
then
echo $i
exit 0
fi
done
exit 1