Skip to content

Commit 96f52ee

Browse files
committed
all the seaport code
1 parent 98ecda9 commit 96f52ee

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

p2p_client.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
#!/bin/bash
4+
5+
curl -v -XPOST localhost:`curl localhost:12480` -F"data=@$HOME/flower_photos/daisy/21652746_cc379e0eea_m.jpg"

p2p_proxy.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Usage : node p2p_proxy.js
2+
const seaportServer = require('seaport').createServer()
3+
seaportServer.listen(12481)
4+
const proxy = require('http-proxy').createProxyServer({})
5+
proxy.on('error', () => console.log('proxy error'))
6+
7+
let i = 0
8+
require('http').createServer((req, res) => {
9+
seaportServer.get('tf_classify_server', worker_ports => {
10+
const this_port = worker_ports[ (i++) % worker_ports.length ].port
11+
res.end(`${this_port}\n`)
12+
})
13+
}).listen(12480)
14+
console.log(`P2P seaport proxy listening on ${12480} to '${'tf_classify_server'}' servers registered to ${12481}`)

test_tf_classify_server.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
#bash tf_classify_server.sh &
4-
#echo 'started server ; sleeping 5'
5-
#sleep 5
3+
bash tf_classify_server.sh &
4+
echo 'started server ; sleeping 5'
5+
sleep 5
66
curl -v -XPOST localhost:12480 -F"data=@$HOME/flower_photos/daisy/21652746_cc379e0eea_m.jpg"

tf_classify_client.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
curl -v -XPOST localhost:12480 -F"data=@$HOME/flower_photos/daisy/21652746_cc379e0eea_m.jpg"
File renamed without changes.

0 commit comments

Comments
 (0)