Pomelo源碼及wiki網址:https://github.com/NetEase/pomelo
在中文wiki中有兩種安裝方式:
第一種是:
npm install pomelo -g
- cd /home/server #目錄可以自定義
第二種是:
git clone https://github.com/NetEase/pomelo.git
cd pomelo
npm install -g
至此Pomelo就安裝完成了,接下來,筆者就將部署第一個Helloworld!
首先,需要在pomelo的文件夾外新建一個文件夾Helloworld,並進入該文件夾:
mkdir Helloworld
cd Helloworld
- 1
- 2
- 3
然後初始化Pomelo工程:
pomelo init
- 1
- 2
在下面的選項中,筆者選擇的是
1
- 1
- 2
for web socket(native socket)
初始化之後,運行Helloworld下的安裝腳本:
sh npm-install.sh
至此pomelo工程就部署成功了,接下來跑起來吧,Helloworld!
在Helloworld目錄下,有三個文件夾,分別是:
- game-server
- web-server
- shared
shared是game-server與web-server的共享目錄,現在不用管。
首先進入game-server目錄,並運行:
cd game-server/
pomelo start -D
- 1
- 2
- 3
pomelo命令後添加”-D”是爲了讓其在後臺運行。
然後進入web-server目錄,並運行:
cd..
cd web-server/
node app
至此,服務器就運行起來了
#cd ./web-server/public
#vim index.html
修改index.html 中var host = "127.0.0.1";爲var host = "
你的服務器ip
";
此時
現game server is ok點擊‘Test Game Server’按鈕
,就會出 消息框。
啓動瀏覽器,運行http://你的服務器ip:3001/,看到pomelo的歡迎頁面
記得開放端口
https://blog.csdn.net/u012741077/article/details/50489732
https://blog.csdn.net/jonahzheng/article/details/27658985