diff --git a/src/announce.js b/src/announce.js deleted file mode 100644 index 7eea6a32c..000000000 --- a/src/announce.js +++ /dev/null @@ -1,65 +0,0 @@ -/* jslint node: true */ - -'use strict'; - -var assert = require('assert'), - debug = require('debug')('installer:announce'), - fs = require('fs'), - os = require('os'), - superagent = require('superagent'); - -exports = module.exports = { - start: start, - stop: stop -}; - -var gAnnounceTimerId = null; - -var ANNOUNCE_INTERVAL = parseInt(process.env.ANNOUNCE_INTERVAL, 10) || 60000; // exported for testing - -function start(apiServerOrigin, callback) { - assert.strictEqual(typeof apiServerOrigin, 'string'); - assert.strictEqual(typeof callback, 'function'); - - if (fs.existsSync('/home/yellowtent/box')) { - debug('already provisioned, skipping announce'); - return callback(null); - } - - debug('started'); - - gAnnounceTimerId = setInterval(doAnnounce.bind(null, apiServerOrigin), ANNOUNCE_INTERVAL); - doAnnounce(apiServerOrigin); - - callback(null); -} - -function stop(callback) { - assert.strictEqual(typeof callback, 'function'); - - debug('Stopping announce'); - - clearInterval(gAnnounceTimerId); - gAnnounceTimerId = null; - - callback(null); -} - -function doAnnounce(apiServerOrigin) { - // On Digital Ocean, the only value which we can give a new droplet is the hostname. - // We use that value to identify the droplet by the appstore server when the droplet - // announce itself. This identifier can look different for other box providers. - var hostname = os.hostname(); - var url = apiServerOrigin + '/api/v1/boxes/' + hostname + '/announce'; - debug('box with %s.', url); - - superagent.get(url).timeout(10000).end(function (error, result) { - if (error || result.statusCode !== 200) { - debug('unable to announce to app server, try again.', error); - return; - } - - debug('success'); - }); -} - diff --git a/src/server.js b/src/server.js index 71106a65f..a92b4a7dd 100755 --- a/src/server.js +++ b/src/server.js @@ -4,8 +4,7 @@ 'use strict'; -var announce = require('./announce.js'), - assert = require('assert'), +var assert = require('assert'), async = require('async'), debug = require('debug')('installer:server'), express = require('express'), @@ -62,8 +61,6 @@ function provision(req, res, next) { debug('provision: received from appstore %j', req.body); - announce.stop(function () { }); - next(new HttpSuccess(202, { })); } @@ -228,7 +225,6 @@ function start(callback) { debug('Using apiServerOrigin from metadata: %s', apiServerOrigin); async.series([ - announce.start.bind(null, apiServerOrigin), startUpdateServer, startProvisionServer, installer.provision.bind(null, userData) @@ -240,7 +236,6 @@ function stop(callback) { assert.strictEqual(typeof callback, 'function'); async.series([ - announce.stop, stopUpdateServer, stopProvisionServer ], callback); diff --git a/src/test/installer-test.js b/src/test/installer-test.js index b53b7e40e..6d7670282 100644 --- a/src/test/installer-test.js +++ b/src/test/installer-test.js @@ -108,33 +108,6 @@ describe('Server', function () { }); }); - describe('provision - announce', function () { - var failingGet = null; - - before(function (done) { - process.env.ANNOUNCE_INTERVAL = 20; - - var scope = nock(APPSERVER_ORIGIN); - failingGet = scope.get('/api/v1/boxes/' + FQDN + '/announce'); - failingGet.times(5).reply(502); - - server.start(done); - }); - - after(function (done) { - process.env.ANNOUNCE_INTERVAL = 60000; - // failingGet.removeInterceptor({ hostname: 'appserver' }); - server.stop(done); - }); - - it('sends announce request repeatedly', function (done) { - setTimeout(function () { - expect(failingGet.counter).to.be.below(6); // counter is nock update - done(); - }, 100); - }); - }); - describe('provision - restore', function () { var data = { sourceTarballUrl: 'https://sourceTarballUrl',