Meteor

[Mobile version(QRCode)]
Access record[Graph / PV Info.(Past 1 day / Past 1 week) / Access from outside (Yesterday / Past 1 week) / Vistors's list]
ProfilePmail(Mail)
Inbox   /Send   /Sent
Reviews(List   /Limit)
Poll   /Agree:Got   /Sent
Fan
Works/Music
Blog
[Write]
Links
My Play List
 Created dateCategoryArticle title
12017/08/13MeteorDeploy meteor app with pm2..
22017/07/27MeteorHow to make Android App ru..
32017/07/21MeteorHow to set title for meteo..
42017/07/20MeteorChange CSS based on settin..
52017/07/20MeteorHow to use config file of ..
62017/07/07MeteorHow to add new class
72017/06/14MeteorHow to sychronize the retu..
82017/04/16MeteorTips
92017/04/15MeteorHow to integrate multiple ..
102017/04/01MeteorHow to create offline app ..
=>Older article
 Created dateNameRecent messages

1.
Update on 2017/08/30 "Meteor > Deploy meteor app with pm2-meteor, nginx, free https(Let's Encrypt) instead of mup(mupx) or galaxy"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Background
2. Install meteor app on remote server
    1. About reference
    2. Choose VPS or some cloud environment using pm2-meteor
    3. Preparation on remote Linux
    4. Preparation on Client side
3. Set up SSL Certificate (HTTPS) using Let's encrypt
    1. Reference
    2. Procedure on remote server
4. Set up nginx
5. If you want to move your local mongo db's content to remote server

1. Background


mup (mupx)
https://github.com/zodern/meteor-up
are popular tools to deploy meteor to deploy to your own environment, if you are not using galaxy.

But I encountered the problem when I used them with meteor 1.5.x and it was hard to solve just using the tool.
Meteor's deployment was so easy before but now it becomes hard while I haven't touched it for a while, probably due to the lack of power for non-commercial deployment way due to the effort of monetization.

Anyway after some struggles, I succeeded in deploying without them with HTTPS support in another way.
I will share how I did it.
2. Install meteor app on remote server


    1. About reference

https://www.npmjs.com/package/pm2-meteor
    2. Choose VPS or some cloud environment using pm2-meteor

VPS is cheap and worthwhile consideration if you are paying from you personal budget.
I chose ConoHa for it instead of Vultr or Digital Ocean this time.
    3. Preparation on remote Linux

This is the case on CentOS 7.3
yum install nodejs;
yum install npm;
npm install pm2 -g;

# On Amazon Linux, you have to update node.js's version
sudo yum install nodejs npm --enablerepo=epel;

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash

. ~/.nvm/nvm.sh

nvm install 4.6.1


# If you want to install mongodb-server on same remote linux
yum install mongodb mongodb-server;

    4. Preparation on Client side

# On client machine
npm i -g pm2-meteor;

#In the case of project "vps-ranking"
#In meteor's PJ folder
mkdir .deploy
cd .deploy
pm2-meteor init;

#Confirm the content of pm2-meteor.json and edit it if necessary
vi pm2-meteor.json
{
  "appName": "vps-ranking",
  "appLocation": {
    "local": "../"
  },
  "meteorSettingsLocation": "../vps-ranking-settings.json",
  "meteorSettingsInRepo": false,
  "prebuildScript": "",
  "meteorBuildFlags": "--architecture os.linux.x86_64  --server-only",
  "env": {
    "ROOT_URL": "http://vps-ranking.com/",
    "PORT": "3020",
    "MONGO_URL": "mongodb://localhost:27017/vps-ranking"
  },
  "server": {
    "host": "vps-ranking.com",
    "username": "root",
    "deploymentDir": "/opt/meteor-apps",
    "loadProfile": "",
    "nvm": {
      "bin": "",
      "use": ""
    },
    "exec_mode": "cluster_mode",
    "instances": "1",
    "pem": "~/.ssh/id_rsa"
  }
}

pm2-meteor deploy;
pm2-meteor start
pm2-meteor status
pm2-meteor logs
I used port 3020 because I would use nginx for HTTPS
3. Set up SSL Certificate (HTTPS) using Let's encrypt


    1. Reference

https://github.com/nolandg/meteor-lets-encrypt
    2. Procedure on remote server

yum install nginx;
yum install httpd; # This is necessary for verification with 
yum install certbot python2-certbot-apache;
apachectl graceful;#Verify this command will work correctly / We will make apache run temporarily for verification with Let's Encrypt service

wget https://dl.eff.org/certbot-auto
chmod a+x ./certbot-auto;
./certbot-auto;

# Set updating of SSL certificate in cron
crontab -e
00 1 * * 1 /root/certbot-auto renew > /var/log/letsencrypt-renewal.log

# If firewall is stopping the access to port 443, you have to open
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
firewall-cmd --reaload

4. Set up nginx

yum install nginx;
# edit server name
vi /etc/nginx/nginx.conf

# Insert the line into nginx's config from let's encrypt getting the help of the command though we will confirm and edit later
git clone https://github.com/letsencrypt/letsencrypt;
cd letsencrypt/;
./letsencrypt-auto --nginx;

# After it, edit config nginx referencing set lines
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;
    gzip  on;

    server {
        listen       80;
        server_name  vps-ranking.com;
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/vps-ranking.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/vps-ranking.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        
        server_name  vps-ranking.com;
        location / {
            proxy_pass http://vps-ranking.com:3020;
         #   proxy_http_version 1.1;
         #   proxy_set_header Upgrade $http_upgrade; #for websockets
         #   proxy_set_header Connection "upgrade";
         #   proxy_set_header X-Forwarded-For $remote_addr; <= I found these from examples but for some reason this line caused infinitive redirecting loop, so I couldn't use this line
         #   proxy_set_header Host localhost; #  $host;
         }
    }
}

Then start nginx
systemctl start nginx

5. If you want to move your local mongo db's content to remote server

Example on client
mongodump --db vps-ranking
scp -Cpr dump $USER@vps-ranking.com:~/

Example on server side
mongorestore dump


Add comment to this article

2.
Update on 2017/07/29 "Meteor > How to make Android App run using meteor v1.5.x"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Background
2. Assumed procedure of making Making Meteor app run on Android
    1. Assumed environment
    2. Install Java
    3. Install Android Studio
    4. Put workable Android SDK at the proper path
        1. Download workable SDK and put at the proper location ._
        2. Set environment value
    5. Create virtual device using Android SDK
    6. Try to make Android app run
3. Encountered Error
    1. Something is missing
    2. Error related with gradle
    3. Emulator is not invoked
    4. Error: adb: Command failed with exit code 1 Error output: error: device unauthorized
    5. ...E chromium: ERROR:...
    6. Cannot deploy meteor app though you succeeded first time
    7. Meteor App does't talk with remote server

1. Background

Android version doesn't work with Latest Androidd SDK now, so we have to do do many tricks to make it run now.
I encountered many problems to try to make Meteor app run for Android.
It may depend on env but you have to solve the problems one by one and you can succeed in launching Android App at the end.
I will share what I encountered and how I solved them.
2. Assumed procedure of making Making Meteor app run on Android


    1. Assumed environment

Latest Mac OS.
    2. Install Java

brew cask install java
    3. Install Android Studio

https://developer.android.com/studio/index.html
    4. Put workable Android SDK at the proper path

Reading https://guide.meteor.com/mobile.html for Android section, do what is described
      1. Download workable SDK and put at the proper location ._

Download files based on the description like this.
Meteor 1.4.3.1 or later: Android SDK Tools v.25.2.x (mac, linux, windows) or v.26.0.0 or later

Unzip it and remove $ANDROID_HOME/tools and put downloaded tools directory there.
      2. Set environment value

vi ~/.bash_profile
export ANDROID_HOME='/Users/$user/Library/Android/sdk'
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
. ~/.bash_profile;
echo $ANDROID_HOME;
    5. Create virtual device using Android SDK

Start any project and click the device mark and create 1 Android Virtual Device
    6. Try to make Android app run

ex.
meteor run --settings $site-settings.json --mobile-server=https://www.travelplan.world/ android

If it runs without error, it is O.K.
But if not, you have to solve the problem 1 by 1.
3. Encountered Error


    1. Something is missing

Invoke Android studio and install package which is said as missing.
    2. Error related with gradle

Check you whether you did "Download workable SDK and put at the proper location ._ " and "Set environment value"
    3. Emulator is not invoked

# Check what error message is shown
cd .meteor/local/cordova-build/

If simulator is not invoked, type this and check the message.
emulator -avd $EMULATOR_NAME;
    4. Error: adb: Command failed with exit code 1 Error output: error: device unauthorized

Make emulator run first through Android studio or command.
After it type meteor run command.
    5. ...E chromium: ERROR:...

Remove crosswalk package
meteor remove crosswalk;

    6. Cannot deploy meteor app though you succeeded first time

Remove Android Virtual Device and recreate it using Android studio
    7. Meteor App does't talk with remote server

Check the url which you type is accessible without redirection or any error.

ex.
meteor run --settings $site-settings.json --mobile-server=https://www.travelplan.world/ android;

Add comment to this article

3.
Update on 2017/07/20 "Meteor > How to set title for meteor"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

document.title = "......" ;

Add comment to this article

4.
Update on 2017/07/21 "Meteor > Change CSS based on settings.json which you useHow to load customized CSS based on the variable in settings.json"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Example

1. Example

SITE=vps-ranking;
export MONGO_URL="mongodb://127.0.0.1:27017/$SITE";
meteor run --settings $SITE-settings.json --mobile-server=https://$SITE.com/

settings.json
{
    "public": {
        "site": "vps-ranking"
    }
}

components/CustomCss.jsx
import React from 'react';
import { Meteor } from 'meteor/meteor';

const CustomCss = () => {
  let customCss = '/css/site/' + Meteor.settings.public.site + '.css';
  return (
    <link rel="stylesheet" type="text/css" href={customCss} />
  );
};

export default CustomCss;

File which use the file
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
import React from 'react';

import CustomCss from '../imports/ui/components/CustomCss';
...

  render(
    ...
  <CustomCss />
...
  );
...


Add comment to this article

5.
2017/07/20 "Meteor > How to use config file of meteor"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Specify config file
2. How to access to the value internally

1. Specify config file

Example
meteor run --settings vps-ranking-settings.json --mobile-server=https://vps-ranking.com/
2. How to access to the value internally

If you defined the value like
{
  "siteName": "test site name"
}

then you can access the value by

Meteor.settings.siteName

in meteor's program.

Add comment to this article

6.
2017/07/07 "Meteor > How to add new class"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Example
2. api/
3. vi startup/client/routes.jsx
4. vi startup/server/register-api.js
5. ui/components
6. ui/containers
7. pages/

1. Example

When you create States class
$CLASS="States";
2. api/

$class = "states";
mkdir $class;
mkdir -p $class/server;
touch $class/server/publications.js;
touch $class/$class.js;
touch $class/methods.js;
3. vi startup/client/routes.jsx

Add route if necessary
4. vi startup/server/register-api.js


5. ui/components

ui/components/$CLASS.jsx
ui/components/$CLASS.less
6. ui/containers

$CLASSPageContainer.jsx

In the case that new Container.jsx is added, you have to restart meteor.
7. pages/

pages/$CLASS.jsx
pages/$CLASS.less

Add comment to this article

7.
2017/06/14 "Meteor > How to sychronize the returned value from Meteor.call"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

Put program which you want to execute in callback part.

Example
    let count_todos = 0;
    let found_geoinfo = 0;
    todos.map(todo => {
      Meteor.call('addressToGeoinfo.getGeoInfo', {
          newValue: todo
        },
        (err, res) => {
          count_todos++;
          if (err) {
            alert(err);
          }
          else if(typeof res !== 'undefined' && typeof res.geoinfo !== 'undefined' && typeof res.geoinfo[0] !== 'undefined' && typeof res.geoinfo[0].geometry !== 'undefined' && typeof res.geoinfo[0].geometry.location !== 'undefined'){
              Session.set('latlng', [todo.text, res.geoinfo[0].geometry ._ location.lat, res.geoinfo[0].geometry ._ location.lng] );
              this.positions.push([todo.text, res.geoinfo[0].geometry ._ location.lat, res.geoinfo[0].geometry ._ location.lng]);
              found_geoinfo++;
          }
          if(count_todos == todos.length) {
            if( found_geoinfo ) {
              console.dir("result =" + Session.get('latlng'));
              console.log("bind=" + this.positions.length);
              window.initMap = this.initializeFactory(this.positions);//this.positions);
              loadJS('https://maps.googleapis.com/maps/api/js?key=' + Meteor.settings.public.GoogleMapAPIKey + '&callback=initMap');
            }
            else{
              $("#map").html('No drawable locaiton.');
            }
          }
        });
      }
    ) ;


Add comment to this article

8.
2017/04/16 "Meteor > Tips"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

Find more than 20 items

DBQuery.shellBatchSize = 300

Add comment to this article

9.
2017/04/15 "Meteor > How to integrate multiple social accounts for meteor account modules in 2017"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

Methodology and modules are outdated about how to integrate with multiple social accounts for meteor.js.
I managed to find the way about how to do it.

Add the following code to server side's script.
Accounts.onCreateUser(function(options, user) {
        if (user.services) {
            var service = _.keys(user.services)[0];
            var email = user.services[service].email;

// define trustable service 
            if (service == 'github' || service == 'facebook' || service == 'twitter' || service == 'google') {
                if (!user.profile)
                    user.profile = {};
                if (!user.profile.name)
                    user.profile.name = user.services[service].username;
            }
 
            if (!email)
                return user;
 
            // see if any existing user has this email address, otherwise create new
            var existingUser = Meteor.users.findOne({'emails.address': email});
            if (!existingUser)
                return user;
            console.log(user.services);
 
            // precaution, these will exist from accounts-password if used
            if (!existingUser.services)
                existingUser.services = { resume: { loginTokens: [] }};
            if (!existingUser.services.resume)
                existingUser.services.resume = { loginTokens: [] };
 
            // copy across new service info
            existingUser.services[service] = user.services[service];
            existingUser.services.resume.loginTokens.push(
                //user.services.resume.loginTokens[0]
                user.services[service].accessToken
            );
 
            // even worse hackery
            Meteor.users.remove({_id: existingUser._id}); // remove existing record
            return existingUser;                          // record is re-inserted
        }
    });

I modified
http://www.meteorpedia.com/read/Merging_OAuth_accounts
because there are some parts which I cannot use as it is but this helped me to reach this solution.
Red parts are the parts which I modified.

Add comment to this article

10.
2017/04/01 "Meteor > How to create offline app using metoer"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Reference

    1. Reference

https://hackernoon.com/offline-first-react-native-meteor-apps-2bee8e976ec7
https://www.npmjs.com/package/react-native-meteor-redux
https://github.com/reactjs/redux
https://facebook.github.io/react-native/
https://subvisual.co/blog/posts/79-a-bridge-between-redux-and-meteor
https://github.com/rt2zz/redux-persist
https://crater.io/posts/GEpumsQboY8AX9tcA/offline-app-with-meteor-and-cordova

Add comment to this article

=>Older article
Subscribe to RSS
RSS
Display Style of blog
List/Mobile(QRCode)
Term
Category
All
1.Japan
2.Atlassian's products
3.Self
4.Development of this site
5.Japanese comics
6.Japanese anime
7.Weekly hot news of Japanese culture
8.OP/ED/PV
9.Japanese game
10.Ranking
11.Japanese Comics (Manga)
12.Search Engine
13.Japanese drama
14.Japanese otaku culture
15.Programming
16.Ineternet world
17.Movie
18.C/C++
19.BerkeleyDB
20.Apache programming
21.Spam
22Meteor
23.Marketing
24.Python
25.Scrum
26.JIRA
27.Git
28.CI
29.Jenkins
30.AWS
31.Operation
32.Singapore
33.Cloud
34.Mysql Cluster
35.DevOps
36.Bitbucket
37.Xamarin
38.Good and new
39.Monitoring
40.node.js
41.React
42.Phillipines
43.Hiring
44.Python
45.SEO
46.Malaysia
47.Mongodb
48.Perl
49.Docker
50.Life hack
51.JavaScript(node.js)
52.Dance
53.QA
54.Mysql
55.How to dump only schema
56.How to dump only schema
Sayings from S-Cry-Ed

Rule in this world is speed. Even stupid person can write cool novel if he can spend 20 years for it.

If someone helped me, I will help him in return, which is my rule.

To become stronger, consider what is cowardliest thinking. And rebel against the thinking, which will make you stronger.



I am Japanese but working for some English sites.

Doctor Job Career
Nurse Job Career
Top Page top MetaSeachJP Works