src/js/app.js
// provisionNode creates and sets up a droplet for production OpenBazaar use
provisionNode creates and sets up a droplet for production OpenBazaar use
provisionNode creates and sets up a droplet for production OpenBazaar use
function provisionNode() {
  let node = ViewState.nodes[0];
  node.state = NodeStates.CREATING_DROPLET;
  let doClient = new DigitalOcean(App.apiKey);
  return doClient.createDroplet({
    name: node.name,
    size: '512mb',
    region: availableDataCenters[Math.floor(Math.random() * availableDataCenters.length)],
    image: 'ubuntu-14-04-x64',
    user_data: cloudInitScriptTemplate
      .replace('{{vpsPassword}}', node.vpsUser.password)
      .replace('{{obPassword}}', node.obUser.password)
      .replace('{{obRelayBranch}}', obRelayBranch),
  })
  .then(function (data) {
    return waitForCreation(doClient, data.droplet.id);
  })
  .then(function (data) {
    node.ipv4 = data.droplet.networks.v4[0].ip_address;
    node.state = NodeStates.INSTALLING_OPENBAZAAR_RELAY;
    return waitForReadyState(node);
  });
}
function provisionNode ( ) { let node = ViewState . nodes [ 0 ] ; node . state = NodeStates . CREATING_DROPLET ; let doClient = new DigitalOcean ( App . apiKey ) ; return doClient . createDroplet ( { name : node . name , size : '512mb' , region : availableDataCenters [ Math . floor ( Math . random ( ) * availableDataCenters . length ) ] , image : 'ubuntu-14-04-x64' , user_data : cloudInitScriptTemplate . replace ( '{{vpsPassword}}' , node . vpsUser . password ) . replace ( '{{obPassword}}' , node . obUser . password ) . replace ( '{{obRelayBranch}}' , obRelayBranch ) , } ) . then ( function ( data ) { return waitForCreation ( doClient , data . droplet . id ) ; } ) . then ( function ( data ) { node . ipv4 = data . droplet . networks . v4 [ 0 ] . ip_address ; node . state = NodeStates . INSTALLING_OPENBAZAAR_RELAY ; return waitForReadyState ( node ) ; } ) ; }
provisionNode creates and sets up a droplet for production OpenBazaar use
provisionNode creates and sets up a droplet for production OpenBazaar use
// Get node object and update its state // Create a DO client // Perform the provisioning // After creating the droplet we need to wait for it to be active // Once it's active show a message to the user with their details and wait // for the provising to be finished // Now just wait for everything to be ready