Browse Source

storage-node: ensure same dev port is used in init and running

Mokhtar Naamani 4 years ago
parent
commit
7113f85b3e
2 changed files with 12 additions and 9 deletions
  1. 10 4
      storage-node/packages/cli/bin/dev.js
  2. 2 5
      storage-node/packages/colossus/bin/cli.js

+ 10 - 4
storage-node/packages/cli/bin/dev.js

@@ -18,6 +18,10 @@ function roleKeyPair (api) {
   return api.identities.keyring.addFromUri(ROLE_ACCOUNT_URI, null, 'sr25519')
 }
 
+function developmentPort () {
+  return 3001
+}
+
 const check = async (api) => {
   const roleAccountId = roleKeyPair(api).address
   const providerId = await api.workers.findProviderIdByRoleAccount(roleAccountId)
@@ -61,11 +65,12 @@ const init = async (api) => {
 
   console.log('Running setup')
 
-  // set localhost colossus as discovery provider on default port
+  // set localhost colossus as discovery provider
   // assuming pioneer dev server is running on port 3000 we should run
-  // the storage dev server on port 3001
+  // the storage dev server on a different port than the default for colossus which is also
+  // 3000
   debug('Setting Local development node as bootstrap endpoint')
-  await api.discovery.setBootstrapEndpoints(alice, ['http://localhost:3001/'])
+  await api.discovery.setBootstrapEndpoints(alice, [`http://localhost:${developmentPort()}/`])
 
   debug('Transfering tokens to storage role account')
   // Give role account some tokens to work with
@@ -155,5 +160,6 @@ module.exports = {
   init,
   check,
   aliceKeyPair,
-  roleKeyPair
+  roleKeyPair,
+  developmentPort
 }

+ 2 - 5
storage-node/packages/colossus/bin/cli.js

@@ -253,8 +253,9 @@ const commands = {
     let publicUrl, port, api
 
     if (cli.flags.dev) {
+      const dev = require('../../cli/bin/dev')
       api = await init_api_development()
-      port = 3001
+      port = dev.developmentPort()
       publicUrl = `http://localhost:${port}/`
     } else {
       api = await init_api_production(cli.flags)
@@ -264,10 +265,6 @@ const commands = {
 
     return start_colossus({ api, publicUrl, port })
   },
-  // 'down': async () => {
-  //   const api = await init_api_as_storage_provider()
-  //   await go_offline(api)
-  // },
   'discovery': async () => {
     debug('Starting Joystream Discovery Service')
     const { RuntimeApi } = require('@joystream/runtime-api')