Skip to content

Commit

Permalink
Merge pull request #87 from theunknownartisthour/patch-2
Browse files Browse the repository at this point in the history
Adding a bit more on Openshift Install
  • Loading branch information
julianlam committed Apr 12, 2016
2 parents 064e590 + 75692e9 commit ec924cc
Showing 1 changed file with 131 additions and 73 deletions.
204 changes: 131 additions & 73 deletions installing/cloud/openshift.rst
Original file line number Diff line number Diff line change
@@ -1,133 +1,191 @@
Openshift PaaS
===========

**Notice: ** A quickstart has been made to handle much of the below by using openshift's environment variables. If you're just getting started please take a look at <a href="https://github.com/ahwayakchih/openshift-nodebb" target="_blank">https://github.com/ahwayakchih/openshift-nodebb</a>
Notice
---------------------------------------
A quickstart has been made to handle much of the below by using openshift's environment variables. If you're just getting started please take a look at `ahwayakchih's openshift repo <https://github.com/ahwayakchih/openshift-nodebb>`_

The following are installation instructions for the `Openshift <http://openshift.com>`_ PaaS. Before starting, you need to install Red Hat's rhc command line at `https://developers.openshift.com/en/managing-client-tools.html <https://developers.openshift.com/en/managing-client-tools.html>`_

The following are installation instructions for the `Openshift <http://openshift.com>` PaaS. Before starting, you need to install Red Hat's rhc command line at <a href="https://developers.openshift.com/en/managing-client-tools.html" target="_blank">https://developers.openshift.com/en/managing-client-tools.html</a>
**Step 1:** Create an application:

**Step 1:** Go to <a href="https://openshift.redhat.com/app/console/applications" target="_blank">https://openshift.redhat.com/app/console/applications</a> and then create an application.
You may do this through `your web console <https://openshift.redhat.com/app/console/applications>`_ or by using rhc:

**Step 2:** Scroll down and choose Node.js 0.10 in "Other types". Then click 'Next'.
.. code:: bash
rhc app create nodebb nodejs-0.10
**Step 3:** Type `nodebb` in application name. If you want another name, you might want this instead: `nodebb-(name)`. Replace `(name)` to whatever you like.
Note: If it's your first time, you will see a note saying you need to specify a namespace. Namespace can be anything ... as long you do not change application name.
If you're using the web console:

**Step 4:** Scroll all the way down and click 'Create Application'. Then you need to wait for it to finish creating your first NodeBB application.
Note: Do not make any changes to your application, just leave them as it is. Otherwise do it at your own risk as NodeBB might will not work correctly.
Scroll down and choose Node.js 0.10 in "Other types". Then click 'Next'. Type `nodebb` in application name or replace `(name)` to whatever you like.

**Step 5:** You will be asked if you want to code your application. Simply click 'Not now, contiune'. Then you will be redirected to an application page. It will tell you that it is created without any errors and it is started.
You may see a note indicating you need to specify a namespace. Namespace can be anything as long you do not change the application name. If you do add a namespace make sure to use them in your RHC commands with -n and use -a to target you application by name.

**Step 6:** Click 'see the list of cartridges you can add'. Choose the MongoDB cartridge. Then click 'Next'. You should see if you want to confirm. Click 'Add Cartridge'.
.. code:: bash
rhc app create -a nodebb -n mynamespace nodejs-0.10
**Step 7:** You should see the notice that it is installed without any errors. It also will tell you the credentials you need to use to access it. Write it down somewhere, as you will need it later.
Scroll all the way down and click 'Create Application'. Then you need to wait for it to finish creating your first NodeBB application.

You will be asked if you want to code your application. Simply click 'Not now, contiune'. Then you will be redirected to an application page. It will tell you that it is created without any errors and it is started.

**Step 2:** Add a Database:

NodeBB works with eaither Redis or MongoDB, we'll use MongoDB.

.. code:: bash
rhc cartridge add mongodb-2.4 -a nodebb
In the web console:

Click 'see the list of cartridges you can add'. Choose the MongoDB cartridge. Then click 'Next'. You should see if you want to confirm. Click 'Add Cartridge'.

**Step 3:** Note your Database Credentials.

After installing the cartridge you'll get a notification of your username and password. Write it down somewhere, as you will need it later.

Open terminal (or Git Bash) and paste the following command to access SSH.

.. code:: bash
rhc app ssh -a nodebb
**Step 9:** Open terminal (or Git Bash) and paste the following command to access SSH.
```
rhc app ssh -a nodebb
```
Note: If you got an error that it does not exist or similar, you need to do the following command and then try again.
```
rhc setup
```

**Step 9:** Paste the following command. Then save the necessary information.
```
echo $OPENSHIFT_NODEJS_IP && echo $OPENSHIFT_MONGODB_DB_HOST && echo $OPENSHIFT_MONGODB_DB_PORT
```
.. code:: bash
rhc setup
Get your Database's Host, IP and Port

Save this for later as well...

.. code:: bash
echo $OPENSHIFT_NODEJS_IP && echo $OPENSHIFT_MONGODB_DB_HOST && echo $OPENSHIFT_MONGODB_DB_PORT
In order:
First line: NodeJS IP address - You should save it.
Second line: Mongodb IP address - Write it down.
Third line: Mongodb Port - Write it down.

**Step 10:** Exit SSH by pasting the following command.
```
exit
```
Now exit SSH by pasting the following command.

.. code:: bash
exit
Note: You might have to type 'exit' once, and then again to exit SSH completely.

**Step 11:** Go back to <a href="https://openshift.redhat.com/app/console/applications" target="_blank">https://openshift.redhat.com/app/console/applications</a> and then click NodeBB application. Copy the URL address from "Scoure Code."
**Step 4:** Add NodeBB's Source Code on Openshift:

Go back to [https://openshift.redhat.com/app/console/applications](https://openshift.redhat.com/app/console/applications) and then click NodeBB application. Copy the URL address from "Scoure Code."

A similar scoure code URL address should be this: ssh://[code]@nodebb-[namespace].rhcloud.com/~/git/nodebb.git/

**Step 12:** Go back to terminal. Paste the following command and then paste the URL address.
```
git clone ssh://[code]@nodebb-[namespace].rhcloud.com/~/git/nodebb.git/
```
Go back to terminal. Paste the following command and then paste the URL address.

Note: If it exists, check to make sure you do not have more than four files. If it is, delete it and rerun the command. Otherwise contiune to next step.
.. code:: bash
git clone ssh://[code]@nodebb-[namespace].rhcloud.com/~/git/nodebb.git/
Note: If it exists, check to make sure you do not have more than four files. If it is, delete it and rerun the command. Otherwise continue on.

Note: This will create NodeBB folder on your computer, usually ~/users/[name]/NodeBB

**Step 13:** Then cd to NodeBB folder on your computer. And you will need to clone NodeBB from Github to your application by using this command. The default command git clone will not work with Openshift, unless you're in SSH. You may split up this command into two parts if you needed to clone your repository to another part of your computer start git bash from there.
```
cd nodebb && git remote add upstream -m master https://github.com/NodeBB/NodeBB.git
Then cd to NodeBB folder on your computer. And you will need to clone NodeBB from Github to your application by using this command. The default command git clone will not work with Openshift, unless you're in SSH. You may split up this command into two parts if you needed to clone your repository to another part of your computer start git bash from there.

.. code:: bash
cd nodebb && git remote add upstream -m master https://github.com/NodeBB/NodeBB.git
or
cd nodebb
git remote add upstream -m master https://github.com/NodeBB/NodeBB.git
```

**Step 14:** Then pull files from NodeBB's repository.
```
git pull -s recursive -X theirs upstream v0.9.x
```
Openshift does not yet support version `1.0.0` or later, see [this issue](https://github.com/ahwayakchih/openshift-nodebb/issues/17).
.. code:: bash
**Step 15:** Now you will need to commit and push files to your application's repository. Replace `message` with your message. It will take a while to finish, though.
```
git commit -a -m 'message' && git push
```
cd nodebb
git remote add upstream -m master https://github.com/NodeBB/NodeBB.git
**Step 16:** Access SSH again.
```
rhc app ssh -a nodebb
```
**Step 17:** First `cd` then start the installation of NodeBB using interactive installer.
```
cd ~/app-root/repo && ./nodebb setup
```
Then pull files from NodeBB's repository.

Note: Web installer (npm start) might will not work because... it's Openshift.
.. code:: bash
git pull -s recursive -X theirs upstream v0.9.x
Openshift does not yet support version `1.0.0` or later, see `this issue on github <https://github.com/ahwayakchih/openshift-nodebb/issues/17>`_.

**Step 5:** Upload the source code to Openshift

Now you will need to commit and push files to your application's repository. Replace `message` with your message. It will take a while to finish.

.. code:: bash
git commit -a -m 'message' && git push
**Step 6:** Configure and Install NodeBB.

SSH back into your application:

**Step 18:** Follow what this step carefully!!!
.. code:: bash
rhc app ssh -a nodebb
Start the installation of NodeBB using interactive installer. You're going to fill in your application's details.

.. code:: bash
cd ~/app-root/repo && ./nodebb setup
Note: Web installer (npm start) might will not work because... it's Openshift.

*URL used to access this NodeBB (http://localhost:4567)* - Copy and paste your application's URL address and then add port 8080 like so: http://nodebb-[namespace].rhcloud.com:8080

*Please enter a NodeBB secret (code)* - Just press enter.

*Which database to use (redis)* - enter `mongo`.

*Host IP or address of your Mongo instance (127.0.0.1)* - Copy & paste Mongo's IP address found in step 9.
*Host IP or address of your Mongo instance (127.0.0.1)* - Copy & paste Mongo's IP address.

*Host port of your Mongo instance (6379)* - Copy & paste Mongo's port found in step 9.
*Host port of your Mongo instance (6379)* - Copy & paste Mongo's port.

*Password of your Mongo database* - Enter your Mongo password found in step 7 or step 9.
*Password of your Mongo database* - Enter your Mongo password.

*Which database to use (0)* - Enter the database name you got in step 7.
*Which database to use (0)* - Enter the database name.

**Step 19:** Now you will need to edit config.json NodeBB had created. Paste the following command.
```
nano config.json
```
**Step 7:** Now you will need to edit config.json NodeBB had created. Paste the following command.

**Step 20:** Add a line below "url" and then add the following. Repleace NodeJS IP Address to IP address of your application found in step 9. Then exit the editor using CTRL+X.
.. code:: bash
nano config.json
Add a line below "url" and then add the following. Repleace NodeJS IP Address to IP address of your application. Then exit the editor using CTRL+X.

```
"bind_address": "NodeJS IP Address",
```

**Step 21:** Now start your NodeBB on Openshift! And you're done! Then visit your website: http://nodebb-[namespace].rhcloud.com/
```
./nodebb start
```
**Step 8:** Now start your NodeBB on Openshift! And you're done! Then visit your website: http://nodebb-[namespace].rhcloud.com/

.. code:: bash
cd ~/app-root/repo && ./nodebb start
Note
---------------------------------------
Starting, stopping, reloading, or restarting NodeBB now works on Openshift. Be sure you always do this before doing it. (Replace `[string]` to a valid string.)
Starting, stopping, reloading, or restarting NodeBB now works on Openshift. Be sure you always do this before doing it. (Replace `[string]` with a nodeBB command of your choice). You can recover your application from critical plugin failures for example by running ./nodebb stop followed by ./nodebb reset -p nodebb-plugin-name

.. code:: bash
rhc app ssh -a nodebb
cd ~/app-root/repo
./nodebb [string]
cd ~/app-root/repo
./nodebb [string]
If you application fails to start after a git push due to an error like EADDRINUSE openshift's application has critically failed and you may want to consider moving your application to a new instance. Look up backing up and exporting databases. You can still resolve the error by first force stopping your application before making a push, but you will have to do this every single git push from now on.

.. code:: bash
rhc app-force-stop -a nodebb
git push origin master

0 comments on commit ec924cc

Please sign in to comment.