Skyhopper on Ubuntu Environment

Hey Guys, I guess you want to checkout and install SkyHopper on your local PC or on an EC2 server with Ubuntu which is a Debian based Linux OS. The purpose of this is to checkout SkyHopper to another linux based OS as currenlty, we only support Amazon Linux for the installation instruction.

Now, here are some tips and instruction when installing the service into Ubuntu Version 14.04 LTS Client or server.

First is to remove old ruby version and upgrade it to version 2.2.4. Please careful not to over-upgrade it a more higher version as it will have dependency problems in the future. As of now we would only use Ruby version 2.2.4

sudo apt-get remove ruby

The next step is to install some dependencies for Ruby.

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev

Next we’re going to be installing Ruby using rbenv. Take note that there are other ways to install ruby that have their own benefits, most people prefer using rbenv these days, but if you’re familiar with rvm you can install using that method as you please. But for now I will just use rbenv.

Installing with rbenv is a simple two step process. First you install rbenv, and then ruby-build:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.2.4
rbenv global 2.2.4
ruby -v

 

Install bundler using gem to get out from dependency hell, and ensures that the gems you need are present.

gem install bundler

Install nodejs and npm for frontend dependencies

sudo apt-get install nodejs nodejs-legacy npm 

Install bower using npm

sudo npm install bower --global

Install necessary development libraries needed 

sudo apt-get install libreadline-gplv2-dev libncurses5-dev zlib-devel ncurses-devel libssl-dev libmysqlclient-dev

Install MySQL Server

To install MySQL, run the following command from a terminal prompt:

sudo apt-get install mysql-server

During the installation process you will be prompted to enter a password for the MySQL root user.

Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:

sudo netstat -tap | grep mysql

When you run this command, you should see the following line or something similar:

tcp        0      0 localhost:mysql         *:*                LISTEN      2556/mysqld

If the server is not running correctly, you can type the following command to start it:

sudo service mysql restart

Then we need to Install Redis

 

To install redis, please follow the instruction written here: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis

Install nginx for websockets, traffic hosting and handling to be used in SkyHopper System.

sudo apt-get install nginx

You will probably be prompted for your user’s password. Enter it to confirm that you wish to complete the installation. The appropriate software will be downloaded to your server and then automatically installed.

We can make sure that our web server will restart automatically when the server is rebooted by typing:

sudo update-rc.d nginx defaults

Then we need to remove the default variable of nginx to replace it with SkyHopper 

sudo rm /etc/nginx/sites-available/default

Then copy the reverse proxy to setup nginx. You might need to change some variables written as it needs to correspond to your skyhopper setup, for example the directory of your skyhopper files are located.

$ sudo tee /etc/nginx/conf.d/skyhopper.conf <<EOF >/dev/null
server {
        listen 80;
        server_name skyhopper.local; #Setup Environment

        ### Production only runs here ###
        location ~ ^/(assets|fonts) {
          root /home/ec2-user/skyhopper/public; # The location of skyhopper cloned directory
        }
        ### Only when running production environment ###

        location / {
            proxy_set_header    X-Real-IP   \$remote_addr;
            proxy_set_header    Host    \$http_host;
            proxy_pass  http://127.0.0.1:3000;
        }

        location /ws {
            proxy_http_version 1.1;
            proxy_set_header    Upgrade \$http_upgrade;
            proxy_set_header    Connection "upgrade";
            proxy_set_header    Host    \$http_host;
            proxy_pass http://127.0.0.1:3210;
        }
}
EOF

Downloading/Cloning SkyHopper from GitHub

$ cd ~ #the directory where you want to install SkyHopper
$ git clone https://github.com/skyarch-networks/skyhopper.git

Up to this point it can be executed by Chef.

Creating MySQL user

$ mysql -uroot

development

mysql> CREATE USER 'skyhopper_dev'@'localhost' IDENTIFIED BY 'your_dev_password';
mysql> GRANT CREATE, SHOW DATABASES ON *.* TO 'skyhopper_dev'@'localhost';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `SkyHopperDevelopment`.* TO 'skyhopper_dev'@'localhost';
mysql> exit

production

mysql> SET storage_engine=INNODB;
mysql> CREATE USER 'skyhopper_prod'@'localhost' IDENTIFIED BY 'your_prod_password';
mysql> CREATE DATABASE IF NOT EXISTS `SkyHopperProduction` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `SkyHopperProduction`.* TO 'skyhopper_prod'@'localhost';
mysql> exit

SkyHopper Setup

$ cd skyhopper

bundle install

$ bundle install --path vendor/bundle

bower install

$ bower install

Compiling TypeScript

$ sudo npm i -g gulp
$ cd frontend/
$ npm i
$ gulp tsd
$ gulp ts
$ cd ..

database.yml

$ cp config/database_default.yml config/database.yml

development

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: skyhopper_dev
  password: 'your_dev_password' #development password that you set earlier
  socket: /var/run/mysqld/mysqld.sock

production

production:
  <<: *default
  database: SkyHopperProduction
  username: skyhopper_prod
  password: 'your_prod_password' #production password that you set earlier

Database Setup

Creating database using rake

$ bundle exec rake db:create

Creating tables using rake

# development
$ bundle exec rake db:migrate
# production
$ bundle exec rake db:migrate RAILS_ENV=production

creating initial data using rake

# development
$ bundle exec rake db:seed
# production
$ bundle exec rake db:seed RAILS_ENV=production

Start

Running Skyhopper

# production
$ ./scripts/skyhopper_daemon.sh start
# usage start|stop|status
# staring mode for daemon
# for development
$ ./scripts/dev_server.sh
# to stop/exit, press: Ctrl + C

Initializing settings for SkyHopper

Perform the initial set up from the browser by accessing SkyHopper

Establishing the Chef Server keys

Copy the installation files under the project directory of SkyHopper tmp/chef to ~/.chef

$ cp -r ~/skyhopper/tmp/chef ~/.chef

 

Congratulations! You have successfully install skyhopper in your system. If you encountered any problems during installation please write comments below. Thank you!

コメントを残す

メールアドレスが公開されることはありません。

Time limit is exhausted. Please reload CAPTCHA.