-
Notifications
You must be signed in to change notification settings - Fork 9
/
shipitfile.js
59 lines (52 loc) · 1.75 KB
/
shipitfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module.exports = function (shipit) {
require('shipit-deploy')(shipit);
require('shipit-shared')(shipit);
shipit.initConfig({
default: {
workspace: '/tmp/shipit_workspace',
deployTo: '/home/admin/apps/rollout_dashboard',
repositoryUrl: 'git@github.com:fiverr/rollout_dashboard.git',
updateSubmodules: true,
ignores: ['.git', 'node_modules'],
branch: process.env.BRANCH || 'master',
timestamp: process.env.TIMESTAMP,
keepReleases: 10,
shallowClone: true,
strict: 'no',
shared: {
dirs: [ 'node_modules', 'logs', 'run' ],
overwrite: true
}
},
production: {
servers: process.env.SERVER_LIST.split(" ")
}
});
function underRelease(cmd) {
return 'cd ' + shipit.config.deployTo + "/current " + ' && ' + cmd;
}
shipit.blTask('startAppProduction', function () {
shipit.remote(underRelease("./control.sh restart production"));
});
shipit.blTask('buildConfigFile', function () {
shipit.remote(underRelease('consul-template -template "./config/app.js:./config/app.js" -once'));
});
shipit.blTask('buildConfigFiles', function () {
shipit.remote(underRelease("./build_config_files.sh " + shipit.config.deployTo));
shipit.emit('configFilesBuilt');
});
shipit.blTask('deployProduction', function () {
shipit.start('buildConfigFiles');
shipit.on("configFilesBuilt", function() {
shipit.start('startAppProduction');
shipit.start('buildConfigFile');
})
});
shipit.on("cleaned", function() {
if (shipit.environment.indexOf("staging") > -1) {
shipit.start('deployStaging');
} else if (shipit.environment.indexOf("production") > -1) {
shipit.start('deployProduction');
}
});
};