Saturday 10 October 2015

Hosting your Meteor App

This is the toughest part, deploying meteor application, all the tutorials i tried are confusing, i myself faced this problem
so decided to write a tutorial on how i was able to successfully host my meteor app

USE MUPX

i hosted my meteor app on dedicated linux server with 1TB hard drive and 16gb ram and ubuntu server os

We are using linux machine, lubuntu was our os , this might not work on windows, we were using linux machine for development



install mupx on your local machine
related link
https://github.com/arunoda/meteor-up/tree/mupx#

npm install -g mupx

node and npm should be installed on your local machine

got to your project directory

cd /projectdirectory

mupx init

this will create mup.json and settings.json file in your project folder

now most important thing is to configure your mup.json file

{
// Server authentication info
"servers": [
    {
"host": "64.23.434.2",
"username": "root",
"password": "rootpassword",
// or pem file (ssh based authentication)
      // WARNING: Keys protected by a passphrase are not supported
      //"pem": "~/.ssh/id_rsa",
      // Also, for non-standard ssh port use this
"sshOptions": { "port" : 7576 },
// server specific environment variables
"env": {}
    }
  ],

// Install MongoDB on the server. Does not destroy the local MongoDB on future setups
"setupMongo": true,

// Application name (no spaces).
"appName": "yourappname",

// Location of app (local directory). This can reference '~' as the users home directory.
  // i.e., "app": "~/Meteor/my-app",
  // This is the same as the line below.
"app": "/home/websol/myproject", <<--- this path is of your local machine where the project files are

// Configure environment
  // ROOT_URL must be set to your correct domain (https or http)
"env": {
"PORT": 80,
"ROOT_URL": "http://yourdomain.com"
//"MONGO_URL": "mongodb://127.0.0.1:27017/meteor",

},

// Meteor Up checks if the app comes online just after the deployment.
  // Before mup checks that, it will wait for the number of seconds configured below.
"deployCheckWaitTime": 120,

// show a progress bar while uploading.
  // Make it false when you deploy using a CI box.
"enableUploadProgressBar": true
}


this is the example of mup.json file of lovenmarrymails


"servers": [
    {
"host": "64.23.232.3", <-- your server ip
"username": "root",
"password": "rootpassword",
// or pem file (ssh based authentication)
      // WARNING: Keys protected by a passphrase are not supported
      //"pem": "~/.ssh/id_rsa",
      // Also, for non-standard ssh port use this
"sshOptions": { "port" : 7576 },
// server specific environment variables
"env": {}
    }

add your server connection details here
host , username, password

if there is ssh root conntion details then it will be ok
if you have diffrent port for sshconnection then mention it

"sshOptions": { "port" : 7576 }

or by default it will take port 22


no mongodb installed on server

// Install MongoDB on the server. Does not destroy the local MongoDB on future setups
"setupMongo": true,

this will install it on docker

better is to choose this option only

if you set  "setupMongo": false,

then you have to specify path in env

but it might give port accessing error so avoid this

/ This is the same as the line below.
"app": "/home/websol/projectfiles",

here you have to give path of your local machine project directory

"env": {
"PORT": 80,
"ROOT_URL": "http://yourdomain.com"
//"MONGO_URL": "mongodb://127.0.0.1:27017/meteor",

},

mention the port and root_url of your project

now your mup.json is configured now

mupx reset

this command will set environment install docker, install mongodb on your server

in this command error will be shown if there is any

like connection problem or installation problem etc.

else your config is right


mupx deploy

this command will upload the bundle on your server

and start your app

now go to web browser and run your root_url you have mentioned

and your meteor app is running

this will bundle your app on server  at /opt/yourapp/current/
location




Friday 14 August 2015

Uploading image with userid, so that 1 can browse photogallery

iam writing this article and also uploading a project so that you can see how it works

i was stuck with this problem
in my project, i allow users to upload multiple images, and they are stored using cfs:filesystem
in 3 types as icon, as thumbnail and actual image

thumbnail images are required so that they show up in browse members and on the profile of the user
and when the user clicks on the members profile he is taken to that particular users photogallery

in order to do that you just need to modify file collection, so that it stores userid in cfs.images.filerecord collection

and the code is
'Template.myForm.events({
    'change .myFileInput': function(event, template) {
        FS.Utility.eachFile(event, function(file) {

var newfile=new FS.File(file)
newfile.userid=Meteor.userId();

            Images.insert(file, function (err, fileObj) {
                //If !err, we have inserted new doc with ID fileObj._id, and                //kicked off the data upload using HTTP            });
        });
    }
});'


the code marked in the red, is all that you got to do to insert userid in cfs.images.filrecord collection
so that you can link those images to a particular user

you can download source code from here

http://www.amincode.com/codes/viewcode?codeid=55cd9712cb64a32fe042636b




Monday 10 August 2015

Meteor: unexpected mongo exit code 100

After you copy of your meteor project folder then this happens

Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod

MongoDB had an unspecified uncaught exception.
Check to make sure that MongoDB is able to write to its database directory.

when i got this error i got scared, since almost whole project has been built and now this error, which doesn't seems to go

iam talking about Linux ubuntu

Solution is simple
you got to erase
rm .meteor/local/db/mongod.lock
from the project folder

if you are on linux ubuntu, you can check the exact file name by doing "ls" command

login as root again
and then type meteor, it shall work

do not do meteor reset, it will erase your database

Meteor Data not displaying

this is common mistake you will have when building meteor app, when you are new

fix is that you need to subscribe to that collection
you have to mention that in .js file for that template

Meteor.subscribe("yourcollection");



Thursday 25 June 2015

Sudden up in open source chat application in meteor

meteor is good and amazing framework to build websites rapidly
and it can be used easily to create chat applications, it is primarily built for that

it seems every one is starting there own github chat project

no.1 rated free chat source code site
http://rocket.chat/






no.2 this is also cool
http://spacetalkapp.com/














no.3 this is ok
http://nullchat.space/


no.4 this is also good
https://githost.io/



Friday 19 June 2015

Review About the Rocket Chat Applicaton

Rocket chat app
http://rocket.chat/

seems to be cool, real time web app, for making chat system, built on meteorjs, a real time framework for developing web apps on top of nodejs

at the first glance app seems to be quite good, but its incomplete , there is no admin panel.
and so many other things missing, it is in development and constant upgrades are going on

its lot of work to build this kind of app, you can download it and add your code and customise it according to your needs





Error while installing in digital ocean /root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:245 throw(ex);

i tried to install
rocket.chat

in my digital ocean cloud hosting alc, but again and again i got the same error

=====================================================================
rocketchat:file: updating npm dependencies -- mkdirp, gridfs-stream, gm...
Unexpected mongo exit code null. Restarting.
=> Exited from signal: SIGKILL

/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:245
                                                throw(ex);
                                                      ^
Error: spawn ENOMEM
  at errnoException (child_process.js:1011:11)
  at ChildProcess.spawn (child_process.js:958:11)
  at Object.exports.spawn (child_process.js:746:9)
  at spawnMongod (/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/run-mongo.js:40:24)
  at launchOneMongoAndWaitForReadyForInitiate (/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/run-mongo.js:414:12)
  at launchMongo (/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/run-mongo.js:612:7)
  at [object Object]._.extend._startOrRestart (/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/run-mongo.js:712:19)
  at [object Object].<anonymous> (/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/run-mongo.js:775:14)
  at runWithEnvironment (/root/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/fiber-helpers.js:139:21)

root@nextdhoom:~/Rocket.Chat# meteor
[[[[[ ~/Rocket.Chat ]]]]]

=====================================================

Searched on the internet but could not find any valid answer
then i realised that it was , since i had purchased a $5 droplet with just 512 memory, it was causing that problem

then i upgraded the droplet to 2GB memory and 40GB SSD disk, and the problem vanished

i was able to successfully install and was able to run the program