OpenShift: rhc commands

Tags

To list all openshift apps
rhc apps

$ rhc apps
angularApp @ http://angularApp-myusername.rhcloud.com/ (uuid: abc33456qwerty78900abce)
--------------------------------------------------------------------------
  Domain:     myusername
  Created:    Jun 26  8:28 PM
  Gears:      1 (defaults to small)
  Git URL:    ssh://abc33456qwerty78900abce@angularApp-myusername.rhcloud.com/~/git/angularApp.git/
  SSH:        abc33456qwerty78900abce@angularApp-myusername.rhcloud.com
  Deployment: auto (on git push)

  icflorescu-nodejs-8.1.2 (Node.js Auto-Updating)
  -----------------------------------------------
    From:    https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml
    Website: http://www.nodejs.org/
    Gears:   1 small

railsApp @ http://railsApp-myusername.rhcloud.com/ (uuid: abc123456efbdced789011bacde)
--------------------------------------------------------------------------
  Domain:     myusername
  Created:    May 30  6:39 PM
  Gears:      1 (defaults to small)
  Git URL:    ssh://abc123456efbdced789011bacde@railsApp-myusername.rhcloud.com/~/git/railsApp.git/
  SSH:        abc123456efbdced789011bacde@railsApp-myusername.rhcloud.com
  Deployment: auto (on git push)

  ruby-2.0 (Ruby 2.0)
  -------------------
    Gears: Located with mysql-5.5, phpmyadmin-4

  mysql-5.5 (MySQL 5.5)
  ---------------------
    Gears:          Located with ruby-2.0, phpmyadmin-4
    Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
    Database Name:  abcd
    Password:       qwerty
    Username:       asdf

  phpmyadmin-4 (phpMyAdmin 4.0)
  -----------------------------
    Gears:          Located with ruby-2.0, mysql-5.5
    Connection URL: https://railsApp-myusername.rhcloud.com/phpmyadmin/

To list all environment variables.
rhc env-list {APPNAME}

$ rhc env-list mywebapp
OPENSHIFT_MYSQL_DB_DBNAME=mywebapp

To set the environment variable.
rhc env-set OPENSHIFT_MYSQL_DB_DBNAME={MYSQLDBNAME} –app {MYAPPNAME}

$ rhc env-set OPENSHIFT_MYSQL_DB_DBNAME=tweetblog --app mywebapp

rhc tail -a {APPNAME}

Github API

Tags

Github API
complete reference: https://developer.github.com/enterprise/2.4/v3/

============================
Possible Triggers
============================
Any new issue
-triggers everytime any new issue is opened in a repository you own/collaborate on.
opt_type=ISSUES

Any closed issue
-triggers everytime any issue is closed in a repo you own/collaborate on.

New issue assigned to you
-triggers everytime a new issue is assigned to you.

New repository by a specific username or organization
-triggers everytime a new repository is created by the username or organization you specify.

Any new gist
-triggers everytime new snippets is created/updated

Any published release event
-triggers when a release is published.

Any pull request event
-triggers when a pull request is assigned, unassigned, labeled, unlabeled, opened, closed, reopened, or synchronized.
opt_type=PULL_REQUEST

Any push event
-triggers everytime a repo branch is pushed to.
opt_type=PUSH

Starred a repository
-triggers everytime a user stars a repo.
opt_type=WATCH

============================
Possible Actions
============================
Issues
* Create/Read/Update an issue
Any user with pull access to a repository can create an issue.

Repositories
* Create/Read/Update/Delete a repository
Create a new repository for the authenticated user.

* Create/Read/Update/Delete a release
Users with push access to the repository can create a release.

* Create/Read/Update/Delete a commit comment
* Create/Read/Update/Delete a file
This method creates a new file in a repository

* Create a fork
Create a fork for the authenticated user.

Git Data
* Create a blob
Supported encoding: “utf-8” and “base64”. Default: “utf-8”.
* Create a commit
* Create a Tag Object

Gist
* Create/Read/Update/Delete a gist
* Star/Unstar a gist

Organization
* Create/Read/Update/Delete a team
In order to create a team, the authenticated user must be a member of :org

* Add/Remove team member
In order to add a user to a team, the authenticated user must have‘admin’ permissions to the team or be an owner of the organization that the team is associated with,
and the user being added must already be a member of atleast one other team on the same organization.

* Add/Remove team repository
In order to add a repository to a team, the authenticated user must be anowner of the org that the team is associated with.
Also, the repository mustbe owned by the organization, or a direct fork of a repository owned by theorganization.

Pull Request
* Create/Read/Update a pull request

CREATE monitoring
curl -X POST http://localhost:3010/api/monitor/ \
-H “Content-Type: application/json” \
-d ‘{ “recipeId” : “7af2ecfdee0909096564a36af31c55e9”, “token”: “0e98ec3cb08ba332a2ec9aaf16813ece46fe8fcf”, “repo”: “test”, “owner”: “ortegaaa”, “event”: “watch” }’

DELETE monitoring
curl -X DELETE http://localhost:3010/api/monitor/ \
-H “Content-Type: application/json” \
-d ‘{ “token”: “0e98ec3cb08ba332a2ec9aaf16813ece46fe8fcf”, “webhookUrl”: “https://github.com/api/v3/repos/ortegaaa/test/hooks/102205” }’

How to deploy Node.js app using IBM Bluemix DevOps

Tags

How to deploy Node.js apps using IBM Bluemix DevOps
1. Create Cloud Foundry App -> Select Cloud Foundry Apps -> Select SDK for Node.js
2. Once the app was successfully created look for the Git repo and checkout it to your local machine.
3. To check the Git repo go to https://git.ng.bluemix.net/dashboard/projects
4. Checkout the source code and modified it. The source code contains a minimal boilerplate Node.js code.
5. Test it locally and once it works in your local then it is good to push to master branch.
6. On executing the git push command, the Bluemix will auto-deploy your app.

How to check the progress of your Build
1. Go to Services menu -> Click DevOps menu
2. Go to Pipelines -> then select the pipeline that you want to see. That’s it!

Docker common problems and its solution

Tags

Problem: When running any docker command, the error below is printed

$ docker version

Client:
Version: 1.12.0-rc3
API version: 1.24
Go version: go1.6.2
Git commit: 91e29e8
Built: Sat Jul 2 00:17:11 2016
OS/Arch: windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: The system cannot find the file specified.

$ docker ps -a

An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1: open //./pipe/docker_engine: The system cannot find the file specified.

Solution:
We need to configure the shell to be able to execute docker commands.

webdev@localhost ~
$ docker-machine env

export DOCKER_TLS_VERIFY=”1″
export DOCKER_HOST=”tcp://192.168.99.100:2376″
export DOCKER_CERT_PATH=”C:\Users\webdev\.docker\machine\machines\default”
export DOCKER_MACHINE_NAME=”default”
# Run this command to configure your shell:
# eval $(“C:\Program Files\Docker Toolbox\docker-machine.exe” env)
For cmd, use this command:

eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

For cygwin, use this command:

$ eval $("C:/Program Files/Docker Toolbox/docker-machine.exe" env default)

For set permanent variable easily:
1.Right-click on the Windows Button
2.Select System, from the menu.
3.From there, select “Advanced system settings” → “Environment Variables”
4.Under the System Variables section, add all variables displayed when you ran the command: docker-machine env

Mysql basic commands

Tags

, ,

mysql> show variables like ‘port’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| port | 3306 |
+—————+——-+
1 row in set (0.00 sec)

mysql> show variables like ‘socket’;
+—————+—————–+
| Variable_name | Value |
+—————+—————–+
| socket | /tmp/mysql.sock |
+—————+—————–+
1 row in set (0.00 sec)

mysql> show variables like ‘hostname’;
+—————+————-+
| Variable_name | Value |
+—————+————-+
| hostname | myhostname |
+—————+————-+
1 row in set (0.00 sec)

How to connect to ClearDB and import your local sql schema.
$ mysql -h us-cdbr-sl-dfw-01.cleardb.net -u abcdefghijkl -D remotedbname -p < C:\Apache24\htdocs\myWebApp\schema.sql

Rails common problems and its solutions

Tags

Problem:
Gem Load Error is: Could not find a JavaScript runtime.

$ rails console
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.1/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/bundle/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `require'
/usr/local/bundle/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `<top (required)>'

Solution A:
Edit the Gemfile and add/uncomment the line:
gem ‘therubyracer’, platforms: :ruby
Solution B:
sudo apt-get install nodejs