Hi everybody,
as I stated recently, what Meteor is missing for me is a solid deployment system. My words [could not have been more correct] / [where a self-fulfilling prophecy], as I was forced this very week to go to https production. Let me relay my quest into Mordor for you…
1) DDP problems @ the client
First of all, I “deployed” a test-version to a server I have in my office. It seemed to work fine - until I got the clients office, where it failed miserably… Nothing worked, not even logging in. Some digging in the debug-console revealed the problem: websockets where being blocked. Boohoo. This turns out to be a known problem. Apparently, this can be remedied by using httpS, as the SSL-encryption prevents the proxy from seeing that a package is actually a websocket-call. So, I needed to set up a server with HTTPS.
2) The Trying with different HOW-TO’s
I started with this, after googling: “ubuntu meteor deploy”. This used mupx
. Googling mupx showed me multiple versions on github, may depricated etc etc. Not confidence inspiring, really, so I googled on. DO is highly regarded, and this how-to looked fine to me. So I started with step one,and carried on. I installed a VPS with Ubuntu 16.04 (always use the last LTS-version, right?) and carried on with apt-gets and what not, until the very last step. That failed.
Turns out, using the last version was not correct in this instance, as 16.04 uses systemd, which does not support start but wants something else. Rather than trying to figure out how to convert the script to systemd-rightness, I whiped the server, installed 14.04 and tried again.
After spending a blissfull afternoon trying to work out how to a) run on a separate user, but b) installing node [using nvm, helped there by folkes on #IRC] but then of course being the wrong user, c) not having the wrong rights to run the script, and d) almost throwing my DELL through the window, I was getting more interested in MUPX by the minute.
3) Bliss with MUPX (that line will rhyme, but only if you read it out loud…)
Lets try with mupx
, shall we? MUP(X) is installed via npm. That was not obvious to me, but I got there eventually. (I’m still not quite clear why, but ok.) There are multiple versions of mup, mupx etc, but I ran first mup, which failed, then I found this how-to. I started to follow that, after wipeing my VPS and reinstalling 14.04.
4) Installing the server
Installing the server seemed easy enough: mupx setup
. But you run that from your local machine and not from the server. Took me another try to get this right. (Yes, I know, it does not state that you should run it from the server, but it seemed logical to me!)
5) mupx init
Takes a very long time (+30 seconds anyway) without any feedback to my by now very tired eyes. But then: green lines! Yes! Then, mupx deploy
. RED lines! NOOOOO!
A few gotchas in this as well:
- you need a fully qualified domainname in the json;
- you need to be able to login with root-access.
Root access? I have been told you are a very bad dog if you bite in root…
6) Root this out!
MUPX really want to log n as root. Ubuntu of course, works with sudo; mupx
will not. Stackoverflow to the rescue; how hard can it be? Logging in as root: done! I can log in as root!
Of course, I could not ssh in as root. That is something else… Took me some time again to realize this. Fixed.
7) SUCCESS, well, sort of!
Now, if i command mupx deploy
, I get… success, success, success RED FAILED; the last step: verifying deployment, fails. With the last line: To see more logs type 'mup logs --tail=50’
If you type this, it is a bit of a bummer, because it will give a new error. (This happens only once, because next time the app run, it will echo the log from your app - but not the first time!)
Ok. Well, it seemed to work, so lets try the browser. And it works!
Of course, we do not have a db, and SSL is not working yet, but at least I have a working app…
8) Uploading the db
I come from a LAMP-platform, so dumping a db and loading it is easy as pi. Turned out, the pie was hidden in in a container, so it could either be eaten allready, or be still be there - no way to tell…
Ok, so I need to use meteordump locally - can do that. Except that is not installed. But Meteor comes with mongo pre-baked? Apparently, without meterdump. You need to install that, not by npm, but with apt. Not from the standard repositories, but using this methode. Done.
Creating a dump now will dump to a directory, and dump every collection in a new file. No worries, seems to be standard operation.
Upload to the server using scp, got it covered…
Now, reading the dump back into your database on the server, poses the problem with the container. Google was getting tired of me by now, but I was allowed one more query for the day. And I got an answer.
And yes, I could login now, and had my application working!
One full day, until this blissfull moment.
But SSL still remained…
9) SSoooLong! (And thanks for all the fish…)
According to the mupx-how-to above, installing a SSL certificate was just adding a few lines to the json, putting the certificate files on the right place, and off you go. Small problem: I got 3 files from my registar, and mupx
expected two. It wanted a certificate and a key, and I had cabundle.crt, certificate.crt and certificate.key. Well, I did not ask for a bundle, so I took the certificate.crt , the certificate.key file, and put them in place. SSL ERROR on deployment…
Luckily, it was a bright new morning, so my new google allotment was active… you need to combine the two files into one!
With sweaty fingers… mupx deploy
:
x Verifying deployment: FAILED
But it works! It even works with SSL!
I am still not sure where the error comes from. But my SSL is working, and my websockets are DDP-ing like never before. I’m still 2 months from deployment, so I booked a 6 week holliday!
Of course, the last is not true.
Oh, deployment is very easy. It only took 1 month from my life in energy, and nearly 2 days in realtime.
But I got there
This document might help someone else. I cannot by any stretch of the imagination be called an expert (as is now clear for experts, who probably stoped reading as paragraph 2). But it just might save anyone some time.
More importantly: I wanted to show how someone not an expert can strugle with this. I know I did!
Warm greetings,
Paul