mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Separate websocket to its own role. Necessary because the app was getting pretty big already, but mostly because our Windows PCs don't like to connect to websockets on port 80, which is what we use for the app.
This commit is contained in:
parent
92be2f1b59
commit
984c45b183
13 changed files with 707 additions and 603 deletions
85
lib/cli.js
85
lib/cli.js
|
@ -402,6 +402,9 @@ program
|
|||
.option('-a, --auth-url <url>'
|
||||
, 'URL to auth client'
|
||||
, String)
|
||||
.option('-w, --websocket-url <url>'
|
||||
, 'URL to websocket client'
|
||||
, String)
|
||||
.option('-r, --storage-url <url>'
|
||||
, 'URL to storage client'
|
||||
, String)
|
||||
|
@ -411,12 +414,6 @@ program
|
|||
.option('--storage-plugin-apk-url <url>'
|
||||
, 'URL to apk storage plugin'
|
||||
, String)
|
||||
.option('-u, --connect-sub <endpoint>'
|
||||
, 'sub endpoint'
|
||||
, cliutil.list)
|
||||
.option('-c, --connect-push <endpoint>'
|
||||
, 'push endpoint'
|
||||
, cliutil.list)
|
||||
.option('-d, --disable-watch'
|
||||
, 'disable watching resources')
|
||||
.action(function(options) {
|
||||
|
@ -426,6 +423,9 @@ program
|
|||
if (!options.authUrl) {
|
||||
this.missingArgument('--auth-url')
|
||||
}
|
||||
if (!options.websocketUrl) {
|
||||
this.missingArgument('--websocket-url')
|
||||
}
|
||||
if (!options.storageUrl) {
|
||||
this.missingArgument('--storage-url')
|
||||
}
|
||||
|
@ -435,6 +435,51 @@ program
|
|||
if (!options.storagePluginApkUrl) {
|
||||
this.missingArgument('--storage-plugin-apk-url')
|
||||
}
|
||||
|
||||
require('./roles/app')({
|
||||
port: options.port
|
||||
, secret: options.secret
|
||||
, ssid: options.ssid
|
||||
, authUrl: options.authUrl
|
||||
, websocketUrl: options.websocketUrl
|
||||
, storageUrl: options.storageUrl
|
||||
, storagePluginImageUrl: options.storagePluginImageUrl
|
||||
, storagePluginApkUrl: options.storagePluginApkUrl
|
||||
, disableWatch: options.disableWatch
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('websocket')
|
||||
.description('start websocket')
|
||||
.option('-p, --port <port>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, process.env.PORT || 7110)
|
||||
.option('-s, --secret <secret>'
|
||||
, 'secret (or $SECRET)'
|
||||
, String
|
||||
, process.env.SECRET)
|
||||
.option('-i, --ssid <ssid>'
|
||||
, 'session SSID (or $SSID)'
|
||||
, String
|
||||
, process.env.SSID || 'ssid')
|
||||
.option('-r, --storage-url <url>'
|
||||
, 'URL to storage client'
|
||||
, String)
|
||||
.option('-u, --connect-sub <endpoint>'
|
||||
, 'sub endpoint'
|
||||
, cliutil.list)
|
||||
.option('-c, --connect-push <endpoint>'
|
||||
, 'push endpoint'
|
||||
, cliutil.list)
|
||||
.action(function(options) {
|
||||
if (!options.secret) {
|
||||
this.missingArgument('--secret')
|
||||
}
|
||||
if (!options.storageUrl) {
|
||||
this.missingArgument('--storage-url')
|
||||
}
|
||||
if (!options.connectSub) {
|
||||
this.missingArgument('--connect-sub')
|
||||
}
|
||||
|
@ -442,19 +487,15 @@ program
|
|||
this.missingArgument('--connect-push')
|
||||
}
|
||||
|
||||
require('./roles/app')({
|
||||
require('./roles/websocket')({
|
||||
port: options.port
|
||||
, secret: options.secret
|
||||
, ssid: options.ssid
|
||||
, authUrl: options.authUrl
|
||||
, storageUrl: options.storageUrl
|
||||
, storagePluginImageUrl: options.storagePluginImageUrl
|
||||
, storagePluginApkUrl: options.storagePluginApkUrl
|
||||
, endpoints: {
|
||||
sub: options.connectSub
|
||||
, push: options.connectPush
|
||||
}
|
||||
, disableWatch: options.disableWatch
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -621,6 +662,10 @@ program
|
|||
, 'app port'
|
||||
, Number
|
||||
, 7100)
|
||||
.option('--websocket-port <port>'
|
||||
, 'websocket port'
|
||||
, Number
|
||||
, 7110)
|
||||
.option('--storage-port <port>'
|
||||
, 'storage port'
|
||||
, Number
|
||||
|
@ -729,14 +774,17 @@ program
|
|||
, options.publicIp
|
||||
, options.authPort
|
||||
)
|
||||
, '--websocket-url', util.format(
|
||||
'http://%s:%d/'
|
||||
, options.publicIp
|
||||
, options.websocketPort
|
||||
)
|
||||
, '--storage-url'
|
||||
, util.format('http://localhost:%d/', options.storagePort)
|
||||
, '--storage-plugin-image-url'
|
||||
, util.format('http://localhost:%d/', options.storagePluginImagePort)
|
||||
, '--storage-plugin-apk-url'
|
||||
, util.format('http://localhost:%d/', options.storagePluginApkPort)
|
||||
, '--connect-sub', options.bindAppPub
|
||||
, '--connect-push', options.bindAppPull
|
||||
].concat((function() {
|
||||
var extra = []
|
||||
if (options.disableWatch) {
|
||||
|
@ -745,6 +793,17 @@ program
|
|||
return extra
|
||||
})()))
|
||||
|
||||
// websocket
|
||||
, procutil.fork(__filename, [
|
||||
'websocket'
|
||||
, '--port', options.websocketPort
|
||||
, '--secret', options.authSecret
|
||||
, '--storage-url'
|
||||
, util.format('http://localhost:%d/', options.storagePort)
|
||||
, '--connect-sub', options.bindAppPub
|
||||
, '--connect-push', options.bindAppPull
|
||||
])
|
||||
|
||||
// storage
|
||||
, procutil.fork(__filename, [
|
||||
'storage-temp'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue