Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.6 #1270

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
41ad395
Improve init logs
zodern Jan 1, 2021
8fd6e5b
Change default image to zodern:0.6.1-root
zodern Jan 1, 2021
7ecef94
Always set upload progress bar to true
zodern Jan 1, 2021
8d608d7
Fix depreciation message when there is no link
zodern Jan 1, 2021
f07c9ba
Expand explanations in sample config
zodern Jan 1, 2021
b61fe99
Merge branch 'master' into release-1.6
zodern Sep 20, 2021
4347630
Minor improvements to default config
zodern Sep 20, 2021
962c61a
Basic implementation of server groups
zodern Sep 22, 2021
3a2f28c
Improve "mup status" when no servers
zodern Sep 22, 2021
26b6670
Weaken eslint rules
zodern Sep 22, 2021
26697e2
Expand server groups
zodern Sep 29, 2021
3a2d136
Allow overriding commands
zodern Sep 29, 2021
7c99c06
Wait for new servers to accept ssh connections
zodern Sep 30, 2021
86fbbc4
Retry installing docker if it fails
zodern Sep 30, 2021
7ab10a0
Combine stderr and stdout logs
zodern Sep 30, 2021
8b3223c
Add ssh key to digital ocean
zodern Sep 30, 2021
eea2825
Relesae 1.6.0-beta.1
zodern Sep 30, 2021
9d7c4e1
Increase combined logs length
zodern Oct 13, 2021
daf2041
Version app bundles
zodern Oct 15, 2021
52a2312
Run setup if needed during reconfig/deploy
zodern Oct 18, 2021
1f26709
Fix lint errors
zodern Oct 18, 2021
33e7bb1
Remove enableUploadProgressBar from example config
zodern Oct 18, 2021
d2fe33e
Fix unit tests
zodern Oct 18, 2021
70f1cfe
Enable useBuiltKit by default
zodern Oct 20, 2021
50ea193
Merge branch 'master' into release-1.6
zodern Oct 20, 2021
f95d7ff
Update getSessionsForServers for server groups
zodern Oct 20, 2021
e259a28
Add "mup meteor shell" command
zodern Oct 20, 2021
9d0ca0f
Add basic graceful shutdown for "mup restart"
zodern Oct 20, 2021
b3534ba
Add basic support for resizing servers
zodern Jan 11, 2022
6b2ce75
Replace __tagPrefix with __tag option
zodern Jan 21, 2022
2dcb060
Release 1.6.0-beta.2
zodern Jan 21, 2022
c897c0b
Merge branch 'master' into release-1.6
zodern Apr 20, 2022
d85a458
Remove unnecessary log
zodern Apr 20, 2022
008a046
Merge branch 'release-1.6' of https://github.com/zodern/meteor-up int…
zodern Apr 20, 2022
ddb9b72
Release 1.6.0-beta.3
zodern Apr 20, 2022
69ee1a0
Merge branch 'master' into release-1.6
zodern Jun 27, 2022
29b7872
v1.6.0-beta.4
zodern Jun 27, 2022
022aaef
Update ssh2 imports
zodern Jun 28, 2022
66a60fe
v1.6.0-beta.5
zodern Jun 28, 2022
fba96ba
Redact Authorization header
zodern Oct 4, 2024
1e18967
Log response time in nginx
zodern Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ parserOptions:
templateStrings: true
unicodeCodePointEscapes: true
rules:
arrow-parens:
- 2
- as-needed
array-bracket-spacing:
- 2
- never
Expand All @@ -58,7 +55,6 @@ rules:
comma-style:
- 2
- last
complexity: [1, 9]
computed-property-spacing:
- 2
- never
Expand Down Expand Up @@ -290,4 +286,4 @@ rules:
newline-per-chained-call: 0
class-methods-use-this: 0
no-empty-function: 0
sort-imports: [2, { memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], ignoreCase: true }]
sort-imports: 0
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Big thanks to @shaiamir for his work on the shared proxy.
- Change mongo version
- Validates `mup.js` and displays problems found in it
- Update message is clearer and more colorful
- `uploadProgressBar` is part of default `mup.js`
- `enableUploadProgressBar` is part of default `mup.js`
- Add trailing commas to mup.js (@ffxsam)
- Improve message when settings.json is not found or is invalid
- Loads and parses settings.json before building the app
Expand Down
9 changes: 2 additions & 7 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ module.exports = {
// make deploys more reliable and easier to troubleshoot
prepareBundle: true,

// (optional, default is false) Uses the new docker image builder
// (optional, default is true) Uses the new docker image builder
// during Prepare bundle. When enabled,
// Prepare Bundle is much faster
useBuildKit: true,
Expand Down Expand Up @@ -236,12 +236,7 @@ module.exports = {
// lets you define which port to check after the deploy process, if it
// differs from the meteor port you are serving
// (like meteor behind a proxy/firewall) (optional)
deployCheckPort: 80,

// Shows progress bar while uploading bundle to server
// You might need to disable it on CI servers
// (optional, default is false)
enableUploadProgressBar: true
deployCheckPort: 80
},

// (optional) Use built-in mongodb. Remove it to use a remote MongoDB
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mup",
"version": "1.5.9",
"version": "1.6.0-beta.5",
"description": "Production Quality Meteor Deployments",
"main": "lib/index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/plugin-api.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('PluginAPI', () => {

describe('_normalizeConfig', () => {
it('should copy meteor object to app', () => {
const expected = { meteor: { path: '../' }, app: { type: 'meteor', path: '../', docker: { image: 'kadirahq/meteord', imagePort: 3000, stopAppDuringPrepareBundle: true } } };
const expected = { meteor: { path: '../' }, app: { type: 'meteor', path: '../', docker: { image: 'zodern/meteor:0.6.1-root', imagePort: 3000, stopAppDuringPrepareBundle: true } } };
const config = { meteor: { path: '../' } };
const result = api._normalizeConfig(config);

Expand Down
89 changes: 89 additions & 0 deletions src/check-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* eslint-disable no-labels */
const crypto = require('crypto');
const fs = require('fs');

const checkers = [];

export function registerChecker(checker) {
checkers.push(checker);
}

function createKey(keyConfig = {}) {
const finalConfig = {
...keyConfig
};
if (finalConfig.scripts) {
finalConfig.scripts = finalConfig.scripts.map(
path => fs.readFileSync(path, 'utf-8')
);
}

return crypto.createHash('sha256')
.update(JSON.stringify(finalConfig))
.digest('base64');
}

export async function checkSetup(pluginApi) {
const checks = await Promise.all(checkers.map(checker => checker(pluginApi)));

console.time('setup check');
const bySession = new Map();
checks.flat().forEach(check => {
let keyHash = createKey(check.setupKey);

check.sessions.forEach(session => {
const config = bySession.get(session) || {
keyHashes: {},
services: [],
containers: []
};

config.keyHashes[check.name] = keyHash;
config.services.push(...check.services || []);
config.containers.push(...check.containers || []);
bySession.set(session, config);
});
});

const promises = [];

bySession.forEach((config, session) => {
const promise = new Promise(resolve => {
session.executeScript(
pluginApi.resolvePath(__dirname, './tasks/assets/check-setup.sh'),
{
vars: config
},
(err, code) => {
resolve(!err && code === 0);
}
);
});
promises.push(promise);
});

const result = await Promise.all(promises);
console.timeEnd('setup check');


return result.every(upToDate => upToDate);
}

export async function updateSetupKeys(api) {
const checks = await Promise.all(checkers.map(checker => checker(api)));

// TODO: parallelize this
for (const check of checks.flat()) {
const setupKeyHash = createKey(check.setupKey);

for (const session of check.sessions) {
// TODO: handle errors. Should retry, and after 3 tries give up
// Shouldn't throw since if the command fails mup will simply setup
// again next time
await api.runSSHCommand(
session,
`sudo mkdir -p /opt/.mup-setup && sudo echo "${setupKeyHash}" > /opt/.mup-setup/${check.name}.txt`
);
}
}
}
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (config.hooks) {
}

function commandWrapper(pluginName, commandName) {
return function() {
return async function() {
// Runs in parallel with command
checkUpdates([
{ name: pkg.name, path: require.resolve('../package.json') },
Expand All @@ -52,6 +52,8 @@ function commandWrapper(pluginName, commandName) {
const api = new MupAPI(process.cwd(), filteredArgv, yargs.argv);
let potentialPromise;

await api.loadServerGroups();

try {
potentialPromise = api.runCommand(`${pluginName}.${commandName}`);
} catch (e) {
Expand Down
19 changes: 18 additions & 1 deletion src/load-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import registerCommand from './commands';
import { registerHook } from './hooks';
import { registerPreparer } from './prepare-config';
import { registerScrubber } from './scrub-config';
import { registerServerSource } from './server-sources';
import { registerSwarmOptions } from './swarm-options';
import { registerChecker } from './check-setup';
import resolveFrom from 'resolve-from';

const log = debug('mup:plugin-loader');
Expand Down Expand Up @@ -72,7 +74,14 @@ export function locatePluginDir(name, configPath, appPath) {
function registerPlugin(plugin) {
if (plugin.module.commands) {
Object.keys(plugin.module.commands).forEach(key => {
registerCommand(plugin.name, key, plugin.module.commands[key]);
let command = plugin.module.commands[key];
registerCommand(
// The __plugin option can be used to change the top-level command
// the command is added to
command.__plugin || plugin.name,
key,
plugin.module.commands[key]
);
});
}
if (plugin.module.hooks) {
Expand All @@ -95,6 +104,14 @@ function registerPlugin(plugin) {
if (plugin.module.swarmOptions) {
registerSwarmOptions(plugin.module.swarmOptions);
}
if (plugin.module.serverSources) {
for (const [type, config] of Object.entries(plugin.module.serverSources)) {
registerServerSource(type, config);
}
}
if (plugin.module.checkSetup) {
registerChecker(plugin.module.checkSetup);
}
}

export function loadPlugins(plugins) {
Expand Down
35 changes: 28 additions & 7 deletions src/nodemiral.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ function createCallback(cb, varsMapper) {
return cb(err);
}
if (code > 0) {
const message = `
------------------------------------STDERR------------------------------------
${logs.stderr.substring(logs.stderr.length - 4200)}
------------------------------------STDOUT------------------------------------
${logs.stdout.substring(logs.stdout.length - 4200)}
------------------------------------------------------------------------------
`;
let message = '';
if (!logs.stderr.length && logs.stdout.length) {
message = logs.stdout.substring(logs.stdout.length - 8400);
} else {
message = `
------------------------------------STDERR------------------------------------
${logs.stderr.substring(logs.stderr.length - 4200)}
------------------------------------STDOUT------------------------------------
${logs.stdout.substring(logs.stdout.length - 4200)}
------------------------------------------------------------------------------
`;
}

return cb(new Error(message));
}
Expand All @@ -82,8 +87,24 @@ function createCallback(cb, varsMapper) {
};
}

// TODO: running hooks should be an option for executeScript instead of
// a separate task
async function runDuringHooks(session, options, callback) {
console.dir(options);
const pluginApi = options._getMupApi();
// console.dir(pluginApi);
try {
await pluginApi._runDuringHooks(options.hookName, session);
} catch (e) {
return callback(e);
}

callback();
}

nodemiral.registerTask('copy', copy);
nodemiral.registerTask('executeScript', executeScript);
nodemiral.registerTask('_runHook', runDuringHooks);

const oldApplyTemplate = nodemiral.session.prototype._applyTemplate;
// Adds support for using include with ejs
Expand Down
Loading
Loading