Skip to content

Commit fff181e

Browse files
committed
Merge branch '1.4.2'
2 parents 200c7c9 + 3e33089 commit fff181e

File tree

8 files changed

+46
-18
lines changed

8 files changed

+46
-18
lines changed

docs/docs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ And then add a docker setup hook to login to your private registry on the server
445445

446446
### Image Port
447447

448-
You can set `meteor.docker.port` to the port to expose from the container. This does not affect the port the app is accessed on, only the port the app runs on inside the docker container.
448+
You can set `meteor.docker.imagePort` to the port to expose from the container. This does not affect the port the app is accessed on, only the port the app runs on inside the docker container.
449449

450450
## Reverse Proxy
451451

@@ -1193,6 +1193,10 @@ Runs the nodemiral task list, and returns a promise. If any of the tasks fail, i
11931193

11941194
Returns a promise. Shows the logs to the user, prefixing the host to each line.
11951195

1196+
#### **commandHistory**
1197+
1198+
Array of objects. Each object is in the format of `{name: 'plugin.commandName'}`, and shows what commands have already been run and in what order.
1199+
11961200
#### **runSSHCommand(server, command)**
11971201
server is an object from `servers` in the config
11981202

src/__tests__/plugin-api.unit.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ describe('PluginAPI', () => {
4646
it('should have "program"', () => {
4747
expect(api).has.property('program');
4848
});
49+
it('should have "commandHistory"', () => {
50+
expect(api).has.property('commandHistory');
51+
});
4952
});
5053
describe('utils', () => {
5154
it('should have resolvePath', () => {
@@ -244,6 +247,11 @@ describe('PluginAPI', () => {
244247
console.log(e);
245248
});
246249
});
250+
251+
it('should update commandHistory', () => {
252+
api.runCommand('test.logs');
253+
expect(api.commandHistory).to.deep.equal([{name: 'test.logs'}]);
254+
});
247255
});
248256

249257
describe('getSessions', () => {

src/plugin-api.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class PluginAPI {
3030
this.settingsPath = program.settings;
3131
this.verbose = program.verbose;
3232
this.program = program;
33+
this.commandHistory = [];
3334

3435
this.validationErrors = [];
3536

@@ -257,17 +258,21 @@ export default class PluginAPI {
257258
}
258259
};
259260
_commandErrorHandler(e) {
261+
log('_commandErrorHandler');
260262
process.exitCode = 1;
261263

262264
// Only show error when not from nodemiral
263265
// since nodemiral would have already shown the error
264266
if (!(e.nodemiralHistory instanceof Array)) {
267+
log('_commandErrorHandler: nodemiral error');
265268
console.error(e.stack || e);
266269
}
267270

268271
if (e.solution) {
269272
console.log(chalk.yellow(e.solution));
270273
}
274+
275+
process.exit(1);
271276
}
272277
runCommand = async function(name) {
273278
if (!name) {
@@ -277,14 +282,16 @@ export default class PluginAPI {
277282
if (!(name in commands)) {
278283
throw new Error(`Unknown command name: ${name}`);
279284
}
285+
286+
this.commandHistory.push({ name });
287+
280288
await this._runPreHooks(name);
281289
let potentialPromise;
282290
try {
283291
log('Running command', name);
284292
potentialPromise = commands[name].handler(this, nodemiral);
285293
} catch (e) {
286294
this._commandErrorHandler(e);
287-
process.exit(1);
288295
}
289296

290297
if (potentialPromise && typeof potentialPromise.then === 'function') {

src/plugins/default/command-handlers.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,8 @@ export function setup(api) {
3333
});
3434

3535
log('exec => mup setup');
36-
const config = api.getConfig();
3736

38-
return api.runCommand('docker.setup')
39-
.then(() => {
40-
if (config.proxy) {
41-
return api.runCommand('proxy.setup');
42-
}
43-
});
37+
return api.runCommand('docker.setup');
4438
}
4539

4640
export function start() {

src/plugins/meteor/assets/meteor-deploy-check.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ APP_PATH=/opt/$APPNAME
55
IMAGE=mup-<%= appName.toLowerCase() %>
66
START_SCRIPT=$APP_PATH/config/start.sh
77
DEPLOY_CHECK_WAIT_TIME=<%= deployCheckWaitTime %>
8-
CONTAINER_IP=$(docker inspect $APPNAME --format "{{.NetworkSettings.IPAddress}}")
9-
DEPLOY_CHECK_URL=$CONTAINER_IP<%= `:${deployCheckPort}` %>
8+
9+
# Check if using host network.
10+
$(docker inspect $APPNAME --format "{{(index .NetworkSettings.Networks)}}" | grep -q '\[host')
11+
HOST_NETWORK=$?
1012

1113
cd $APP_PATH
1214

@@ -52,7 +54,11 @@ while [[ true ]]; do
5254

5355
# If the container restarted, the ip address would have changed
5456
# Get the current ip address right before it is used
55-
CONTAINER_IP=$(docker inspect $APPNAME --format "{{.NetworkSettings.IPAddress}}")
57+
if [[ $HOST_NETWORK == 0 ]]; then
58+
CONTAINER_IP="localhost"
59+
else
60+
CONTAINER_IP=$(docker inspect $APPNAME --format "{{.NetworkSettings.IPAddress}}")
61+
fi
5662

5763
if [[ -z $CONTAINER_IP ]]; then
5864
echo "Container has no IP Address, likely from it restarting."

src/plugins/meteor/assets/templates/start.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ sudo docker network disconnect bridge -f $APPNAME-nginx-proxy
5353
if [ $LOCAL_IMAGE == "false" ]; then
5454
set +e
5555
sudo docker pull <%= docker.image %>
56-
set -e
5756
echo "Pulled <%= docker.image %>"
57+
set -e
58+
59+
else
60+
set -e
5861
fi
5962

6063
sudo docker run \
@@ -94,7 +97,6 @@ sudo cat <<EOT > /opt/$APPNAME/config/nginx-default.conf
9497
client_max_body_size $CLIENTSIZE;
9598
EOT
9699

97-
98100
# We don't need to fail the deployment because of a docker hub downtime
99101
set +e
100102
sudo docker pull jrcs/letsencrypt-nginx-proxy-companion:$LETS_ENCRYPT_VERSION

src/plugins/meteor/utils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
export function checkAppStarted(list, api) {
22
const script = api.resolvePath(__dirname, 'assets/meteor-deploy-check.sh');
3-
const { app, proxy } = api.getConfig();
4-
const exposedPort = app.deployCheckPort || app.env.PORT || 80;
5-
const publishedPort = 80;
3+
const { app } = api.getConfig();
4+
const publishedPort = app.docker.imagePort || 80;
65

76
list.executeScript('Verifying Deployment', {
87
script,
98
vars: {
109
deployCheckWaitTime: app.deployCheckWaitTime || 60,
1110
appName: app.name,
12-
deployCheckPort: proxy ? publishedPort : exposedPort
11+
deployCheckPort: publishedPort
1312
}
1413
});
1514

src/plugins/proxy/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ export const hooks = {
3434
if (api.getConfig().proxy) {
3535
api.runCommand('proxy.status');
3636
}
37+
},
38+
'post.meteor.setup'(api) {
39+
// Only run hook on "mup setup"
40+
const dockerSetup = api.commandHistory.find(({ name }) => name === 'default.setup');
41+
42+
if (api.getConfig().proxy && dockerSetup) {
43+
return api.runCommand('proxy.setup');
44+
}
3745
}
3846
};
3947

0 commit comments

Comments
 (0)