mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Add a poor reverse proxy for local development, the main difference being that everything except websockets now goes through the same port. Makes it easier to understand the production url layout.
This commit is contained in:
parent
cd1f9108ce
commit
6d88a28a2c
3 changed files with 140 additions and 54 deletions
105
lib/cli.js
105
lib/cli.js
|
@ -408,20 +408,15 @@ program
|
|||
})
|
||||
|
||||
program
|
||||
.command('app')
|
||||
.description('start app')
|
||||
.command('poorxy')
|
||||
.description('start a poor reverse proxy for local development')
|
||||
.option('-p, --port <port>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, process.env.PORT || 7100)
|
||||
.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('-u, --app-url <url>'
|
||||
, 'URL to app'
|
||||
, String)
|
||||
.option('-a, --auth-url <url>'
|
||||
, 'URL to auth client'
|
||||
, String)
|
||||
|
@ -437,11 +432,9 @@ program
|
|||
.option('--storage-plugin-apk-url <url>'
|
||||
, 'URL to apk storage plugin'
|
||||
, String)
|
||||
.option('-d, --disable-watch'
|
||||
, 'disable watching resources')
|
||||
.action(function(options) {
|
||||
if (!options.secret) {
|
||||
this.missingArgument('--secret')
|
||||
if (!options.appUrl) {
|
||||
this.missingArgument('--app-url')
|
||||
}
|
||||
if (!options.authUrl) {
|
||||
this.missingArgument('--auth-url')
|
||||
|
@ -459,15 +452,57 @@ program
|
|||
this.missingArgument('--storage-plugin-apk-url')
|
||||
}
|
||||
|
||||
require('./units/poorxy')({
|
||||
port: options.port
|
||||
, appUrl: options.appUrl
|
||||
, authUrl: options.authUrl
|
||||
, websocketUrl: options.websocketUrl
|
||||
, storageUrl: options.storageUrl
|
||||
, storagePluginImageUrl: options.storagePluginImageUrl
|
||||
, storagePluginApkUrl: options.storagePluginApkUrl
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('app')
|
||||
.description('start app')
|
||||
.option('-p, --port <port>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, process.env.PORT || 7105)
|
||||
.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('-a, --auth-url <url>'
|
||||
, 'URL to auth client'
|
||||
, String)
|
||||
.option('-w, --websocket-url <url>'
|
||||
, 'URL to websocket client'
|
||||
, String)
|
||||
.option('-d, --disable-watch'
|
||||
, 'disable watching resources')
|
||||
.action(function(options) {
|
||||
if (!options.secret) {
|
||||
this.missingArgument('--secret')
|
||||
}
|
||||
if (!options.authUrl) {
|
||||
this.missingArgument('--auth-url')
|
||||
}
|
||||
if (!options.websocketUrl) {
|
||||
this.missingArgument('--websocket-url')
|
||||
}
|
||||
|
||||
require('./units/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
|
||||
})
|
||||
})
|
||||
|
@ -681,10 +716,14 @@ program
|
|||
, 'auth secret'
|
||||
, String
|
||||
, 'kute kittykat')
|
||||
.option('--poorxy-port <port>'
|
||||
, 'poorxy port'
|
||||
, Number
|
||||
, 7100)
|
||||
.option('--app-port <port>'
|
||||
, 'app port'
|
||||
, Number
|
||||
, 7100)
|
||||
, 7105)
|
||||
.option('--websocket-port <port>'
|
||||
, 'websocket port'
|
||||
, Number
|
||||
|
@ -793,7 +832,7 @@ program
|
|||
, '--app-url', util.format(
|
||||
'http://%s:%d/'
|
||||
, options.publicIp
|
||||
, options.appPort
|
||||
, options.poorxyPort
|
||||
)
|
||||
])
|
||||
|
||||
|
@ -803,21 +842,15 @@ program
|
|||
, '--port', options.appPort
|
||||
, '--secret', options.authSecret
|
||||
, '--auth-url', util.format(
|
||||
'http://%s:%d/'
|
||||
'http://%s:%d/auth/mock/'
|
||||
, options.publicIp
|
||||
, options.authPort
|
||||
, options.poorxyPort
|
||||
)
|
||||
, '--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)
|
||||
].concat((function() {
|
||||
var extra = []
|
||||
if (options.disableWatch) {
|
||||
|
@ -858,6 +891,24 @@ program
|
|||
, '--storage-url'
|
||||
, util.format('http://localhost:%d/', options.storagePort)
|
||||
])
|
||||
|
||||
// poorxy
|
||||
, procutil.fork(__filename, [
|
||||
'poorxy'
|
||||
, '--port', options.poorxyPort
|
||||
, '--app-url'
|
||||
, util.format('http://localhost:%d/', options.appPort)
|
||||
, '--auth-url'
|
||||
, util.format('http://localhost:%d/', options.authPort)
|
||||
, '--websocket-url'
|
||||
, util.format('http://localhost:%d/', 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)
|
||||
])
|
||||
]
|
||||
|
||||
function shutdown() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue