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

Hook called at the wrong time #913

Open
arggh opened this issue Mar 20, 2018 · 1 comment
Open

Hook called at the wrong time #913

arggh opened this issue Mar 20, 2018 · 1 comment

Comments

@arggh
Copy link

arggh commented Mar 20, 2018

Thanks for taking care of Meteor Up!

I recently updated to the latest version on mup and gave the new hooks-feature a shot.

First, I noticed that my app's downtime increased about 10 seconds while deploying, from 60 seconds to 70 seconds (I have a component which displays a loading banner when connection to server drops).

Second, I noticed that the connection to the server is lost at a different stage than before.

With the previous version, clients would lose connection to server when mup reached the "Start Meteor"-task.

With mup 1.4.3, clients lose connection at the "Prepare Bundle"-stage of the "Pushing Meteor App"-task, which seems strange.

Third, I noticed that the post.meteor.push-hook gets called only after the "Prepare Bundle"-task completes, not after the push to server is completed. Maybe this is intentional, but it would be nice to have some hook called right before the server goes down, right? (Because clients have lost connection to server before the "Prepare Bundle"-task completes...)

Maybe it's a good idea to have a post.meteor.push-hook and a post.meteor.prepare-hook?

arggh@ :~/Development/my-app/.deploy$ mup deploy --show-hook-names
Hook: pre.default.deploy
Hook: post.default.deploy
Hook: pre.meteor.deploy
Hook: pre.meteor.push
Hook: pre.meteor.build
Building App Bundle Locally
Hook: post.meteor.build

Started TaskList: Pushing Meteor App
[s1] - Pushing Meteor App Bundle to the Server
[s1] - Pushing Meteor App Bundle to the Server: SUCCESS
# EXPECTED post.meteor.push HERE
[s1] - Prepare Bundle
# CONNECTION LOST ON CLIENT
[s1] - Prepare Bundle: SUCCESS
Hook: post.meteor.push <----- WHAT IS THIS DOING HERE?
Hook: pre.default.reconfig
Hook: post.default.reconfig
Hook: pre.meteor.envconfig

Started TaskList: Configuring App
[s1] - Pushing the Startup Script
[s1] - Pushing the Startup Script: SUCCESS
[s1] - Sending Environment Variables
[s1] - Sending Environment Variables: SUCCESS
Hook: post.meteor.envconfig
Hook: pre.meteor.start

Started TaskList: Start Meteor
[s1] - Start Meteor
[s1] - Start Meteor: SUCCESS
[s1] - Verifying Deployment
[s1] - Verifying Deployment: SUCCESS
Hook: post.meteor.start
Hook: post.meteor.deploy

Mup version: 1.4.3

Mup config
{
  "servers": {
    “s1”: {
      "host": "1.2.3.4",
      "username": “arggh”
    }
  },
  "hooks": {
    "post.meteor.build": {
      "remoteCommand": ""
    }
  },
  "app": {
    "name": "my-app",
    "path": "../",
    "servers": {
      “s1”: {}
    },
    "buildOptions": {},
    "env": {
      "PORT": 3000,
      "HTTP_FORWARDED_COUNT": 1,
      "ROOT_URL": "https://**",
      "MONGO_URL": "mongodb://**",
      "MONGO_OPLOG_URL": "mongodb://**",
      "NODE_ENV": "production"
    },
    "docker": {
      "image": "abernix/meteord:base",
      "args": []
    },
    "deployCheckWaitTime": 90,
    "type": "meteor"
  }
}
 Config is valid
Output of command
arggh@ :~/Development/my-app/.deploy$ mup deploy --show-hook-names --verbose
Hook: pre.default.deploy
Hook: post.default.deploy
Hook: pre.meteor.deploy
Hook: pre.meteor.push
Hook: pre.meteor.build
Building App Bundle Locally
Hook: post.meteor.build                                                     

Started TaskList: Pushing Meteor App
[s1] - Pushing Meteor App Bundle to the Server
[s1] - Pushing Meteor App Bundle to the Server: SUCCESS
[s1] - Prepare Bundle
base: Pulling from abernix/meteord
c20dc0c5afeb: Already exists
a3ed95caeb02: Already exists
a3ed95caeb02: Already exists
52781f451a84: Already exists
a3ed95caeb02: Already exists
a3ed95caeb02: Already exists
a3ed95caeb02: Already exists
5f8feca11b31: Already exists
649129398dc3: Already exists
926d0760afad: Already exists
5a6214b54a5e: Already exists
a3ed95caeb02: Already exists
a3ed95caeb02: Already exists
Digest: sha256:5138e4ba3c55cc6fabe0ba859f984e9725599a9f53ed5d759dd4f350770a62b2
Status: Image is up to date for abernix/meteord:base
Finished Extracting
Creating Dockerfile
Finished creating Dockerfile
Building image
Sending build context to Docker daemon  154.8MB
Step 1/10 : FROM abernix/meteord:base
# Executing 1 build trigger
 ---> Using cache
 ---> 5ff3bd226396
Step 2/10 : RUN mkdir /built_app || true
 ---> Using cache
 ---> 16eaa5dd0bea
Step 3/10 : COPY ./ /built_app
 ---> Using cache
 ---> ced8be75e596
Step 4/10 : ENV PORT=3000
 ---> Using cache
 ---> 48180e24a644
Step 5/10 : ENV HTTP_FORWARDED_COUNT=1
 ---> Using cache
 ---> 59348689394d
Step 6/10 : ENV ROOT_URL=https://**
 ---> Using cache
 ---> 9a861bc4adfa
Step 7/10 : ENV MONGO_URL=mongodb://**
 ---> Using cache
 ---> cf5e1dbecea9
Step 8/10 : ENV MONGO_OPLOG_URL=mongodb://**
 ---> Using cache
 ---> f3ba638421c0
Step 9/10 : ENV NODE_ENV=production
 ---> Using cache
 ---> ec15a8158235
Step 10/10 : RUN cd  /built_app/programs/server &&     npm install --unsafe-perm
 ---> Using cache
 ---> fd081670a85a
Successfully built fd081670a85a
Successfully tagged mup-my-app:build
Deleted Images:
deleted: sha256:bf7bb861f4e152352a10a0b6ee38746e9ee2c4350f94f12593245be1dcf75f4f
deleted: sha256:85a1131305c00b8a7a6aca66850602fe515bcf373c8086bfdb4c5c35663458d1
deleted: sha256:d7cfa3f11ea400d25312c1a41c766a2f4653ce58c738bfd7e971cb396a83e63f
deleted: sha256:979480bc4a76f44f8238f01712a65ff17fdb081b4fb7604af7ceeafcec870782
deleted: sha256:d8c9c96215adb75bed3fde7b08c2e56947a26ac1f61e908617caa37b930386ca
deleted: sha256:82176219bbd2842f85993c10029dd70c113d484431baa140845cd68d8ef0882f
deleted: sha256:56cc07377552604107f9ad2f44899bae629c897027107e61977c8c29a7b9b958
deleted: sha256:6a19238f2e35a474b14c38becdbd869f28177f88f38bc40be9d319197a80b44b
deleted: sha256:9c2edb3703f83dbb82f017a9e37ca65a4e2a450927196473389cf80c3d076f64
deleted: sha256:4fc19bcf7adcc38be4475f0d70f6745ff25286fb505525ba5dd30aab29c6ea8c

Total reclaimed space: 126.8MB
[s1] - Prepare Bundle: SUCCESS
Hook: post.meteor.push
Hook: pre.default.reconfig
Hook: post.default.reconfig
Hook: pre.meteor.envconfig

Started TaskList: Configuring App
[s1] - Pushing the Startup Script
[s1] - Pushing the Startup Script: SUCCESS
[s1] - Sending Environment Variables
[s1] - Sending Environment Variables: SUCCESS
Hook: post.meteor.envconfig
Hook: pre.meteor.start

Started TaskList: Start Meteor
[s1] - Start Meteor
using image
removing last
Image mup-my-app:latest
Volume
Removing docker containers. Errors about nonexistent endpoints and containers are normal.
my-app
Error response from daemon: endpoint my-app not found
Error: No such container: my-app-frontend
Error response from daemon: endpoint my-app-frontend not found
Error: No such container: my-app-nginx-letsencrypt
Error response from daemon: endpoint my-app-nginx-letsencrypt not found
Error: No such container: my-app-nginx-proxy
Error response from daemon: endpoint my-app-nginx-proxy not found
Finished removing docker containers
fab68a2b4227214573a65eb3a1f3a120905f673417b89ec2ab0a1bb911305041
Ran abernix/meteord:base
[s1] - Start Meteor: SUCCESS
[s1] - Verifying Deployment
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<!DOCTYPE html>
<html>
<head>
……….
</body>
</html>634    0  4634    0     0  71206      0 --:--:-- --:--:-- --:--:-- 73555
[s1] - Verifying Deployment: SUCCESS
Hook: post.meteor.start
Hook: post.meteor.deploy
Output of `mup status`
=> Servers
  - s1: Ubuntu 14.04

=> Docker Status
 - s1: 17.12.1-ce Running

=> Meteor Status
 - s1: running 
    Created at 2018-03-20T13:46:26.861000299Z
    Restarted 0 times
    ENV: 
     - ROOT_URL=https://**
     - PORT=80
     - HTTP_FORWARDED_COUNT=1
     - MONGO_URL=mongodb://**
     - MONGO_OPLOG_URL=mongodb://**
     - NODE_ENV=production
     - METEOR_SETTINGS={"isStaging":true}
     - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
     - METEORD_DIR=/opt/meteord
     - NODE_VERSION=4.8.7
    Published Ports:
     - 80/tcp => 3000
    App running at http://**:80
     - Available in app's docker container: true
     - Available on server: true
     - Available on local computer: true
@zodern
Copy link
Owner

zodern commented Jun 10, 2018

Hooks run before and after commands. For example, you can run mup meteor push to only upload the bundle and prepare it. Right now, the only way to allow hooks between pushing the bundle and preparing it would be to create a new command and task list for preparing the bundle.

I would like to allow hooks to run between the tasks in a task list, but I am not sure what it would look like yet.

First, I noticed that my app's downtime increased about 10 seconds while deploying, from 60 seconds to 70 seconds (I have a component which displays a loading banner when connection to server drops).

In version 1.4.5, there is a new option app.docker.stopAppDuringPrepareBundle which when set to false reduces downtime to the amount of time it takes your app to start, which for many apps is only a few seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants