viernes, 23 de diciembre de 2016

TOMCAT ONLINE APP POWERED BY ZENCONSULTORA

Una vez que creamos nuestra aplicación TOMCAT, nos podemos conectar a la liga :

POWERED BY ZENCONSULTORA

http://mytomcatapp-app314.rhcloud.com/





Vamos a hacer un cambio sencillo en la pagina web index.html

tenemos que posicionarnos en la carpeta correcta donde bajamos el repositorio

hicimos un clon local

  Cloned to:  C:/Users/admin/mytomcatapp

Cloned to:  C:/Users/admin/mytomcatapp

Run 'rhc show-app mytomcatapp' for more details about your app.

C:\Users\admin>gid ad -all
"gid" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

C:\Users\admin>git add --all
fatal: Not a git repository (or any of the parent directories): .git

C:\Users\admin>git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

C:\Users\admin>git add
fatal: Not a git repository (or any of the parent directories): .git

C:\Users\admin>cd C:/Users/admin/mytomcatapp

C:\Users\admin\mytomcatapp>git add --all

Nos tenemos que posicionar en el repositorio GIT de otra forma nos va a enviar los siguientes errores


C:\Users\admin\mytomcatapp>git commit -m "first change"
[master 9d9efee] first change
 1 file changed, 10 insertions(+), 282 deletions(-)
 rewrite src/main/webapp/index.html (99%)

C:\Users\admin\mytomcatapp>git push
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 607 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: Stopping jbossews cartridge
remote: Sending SIGTERM to jboss:442072 ...
                                                                             remote: Building git ref 'master', commit 9d9efee
remote: Using Maven mirror /var/lib/openshift/585dd2202d527187ae000210/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml
remote: Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500)
remote: Maven home: /usr/share/java/apache-maven-3.0.4
remote: Java version: 1.7.0_121, vendor: Oracle Corporation
remote: Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.121/jre
remote: Default locale: en_US, platform encoding: ANSI_X3.4-1968
remote: OS name: "linux", version: "2.6.32-642.6.2.el6.x86_64", arch: "i386", family: "unix"
remote: Found pom.xml... attempting to build with 'mvn --global-settings /var/lib/openshift/585dd2202d527187ae000210/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml clean package -Popenshift -DskipTests'
remote: [INFO] Scanning for projects...



ahora si tenemos el cambio correcto:


liga importante:

https://developers.openshift.com/servers/tomcat/getting-started.html

Getting Started with Tomcat 6/7 (EWS 1.0/2.0)

It’s easy to get up and running with Tomcat on OpenShift and the experience will be very similar to the experience of running it on any Linux system. OpenShift supports both source and WAR file deploys and modification of server.xml. One important caveat - applications will not have write permissions to the webapps directory, so you will have to write content to another directory.
OpenShift uses JBoss EWS 1.0 and 2.0 for Tomcat 6 and 7 respectively. EWS is a hardened and Red Hat supported version of Apache Tomcat. Both versions use Java OpenJDK 1.7.
EWS has had the clustering modules removed so you can not do Tomcat clustering with EWS.

Step 1: Create a Tomcat Application

This tutorial walks through the creation of an application titled mytomcatapp under the domain mydomain. Before going through the rest of the tutorial, make sure to have created an OpenShift account and installed the RHC command line tools.
Once that is completed, open a terminal on a local machine and change into a directory where the source code will be located. Then at the command prompt enter the following command to create a Tomcat application:
$ rhc app-create mytomcatapp tomcat7
or
$ rhc app-create mytomcatapp tomcat6
The output will look something like this:
Using jbossews-2.0 (Tomcat 7 (JBoss EWS 2.0)) for 'tomcat7'

Application Options
-------------------
Domain:     mydomain
Cartridges: jbossews-2.0
Gear Size:  default
Scaling:    no

Creating application 'mytomcatapp' ... done


Waiting for your DNS name to be available ... done

Cloning into 'mytomcatapp'...
Warning: Permanently added 'mytomcatapp-mydomain.rhcloud.com,54.0.0.193' (RSA) to the list of known hosts.

Your application 'mytomcatapp' is now available.

  URL:        http://mytomcatapp-mydomain.rhcloud.com/ 
  SSH to:     541a13a04382ec00000002f3@mytomcatapp-mydomain.rhcloud.com
  Git remote: ssh://541a13a04382ec00000002f3@mytomcatapp-mydomain.rhcloud.com/~/git/mytomcatapp.git/
  Cloned to:  /home/me/git_demo/mytomcatapp 

Run 'rhc show-app mytomcatapp' for more details about your app.
Public URL of application
Location of local Git repository
The application will now be running and accessible at the URL (1) listed in the output. A local git repository for your application was also created in the directory listed under Cloned to (2).

Step 2: Make the First Change

A developer on OpenShift can make code changes on a local machine, check those changes in locally, and then push those changes to OpenShift. One of the primary advantages of Git is that it does not require a continuous online presence in order to run. A developer can easily check in (in Git terminology, commit) and revert changes locally before deciding to upload those changes to OpenShift.

Using the Git Repository

To make the first change, edit index.html in the mytomcatapp/src/main/webapp directory of the local Git repository. Go to the file in the terminal and edit with a command line editor like VIM or EMacs. Alternatively, edit the file using any text editor or IDE. Strip out everything between the two <body> tags and change the content to look like this:
<body>
        <h1>Hello world!</h1>
</body>
Now that you have made this incredibly complicated code change, the code must be deployed to the server. Accomplish this task using Git.
  1. To add the change to the Git repository’s index and stage it for the next commit, use the command git add:
    $ git add --all .
  2. Next commit the staged changes to the Git repository, with a log message to explain the changes:
    $ git commit -m "Your commit message"
  3. Finally, push these changes to the remote OpenShift application.
    $ git push
The output of the push command will first show the git push and then the build process and deployment for the OpenShift application. When the build is finished, go back to the application’s URL (mytomcatapp-mydomain.rhcloud.com) and see a page which just says "Hello World" in nice big font.
This is the basic process to follow when developing an application: git addgit commit, and finally git push.
If you are curious about Git or would like to learn more, the Pro Git book is a great resource.

Step 3: Deploying WAR files

OpenShift also supports WAR files deployment. There are several processes which are each very simple. Please visit the deployment options page for more information.

Other Tips

server.xml

Most of the behavior of Tomcat can be controlled through the server.xml file. In OpenShift you can find server.xml inside your application’s Git repository.
server.xml can be found in the {git repo}/.openshift/config/ directory. Please be careful when making a change to the file. Also, make sure the Tomcat server restarts after making the change.

Hot Deploy and Other Markers

With a normal git push as outlined above, Openshift starts and stops the Tomcat server on each build. For Java applications, a WAR file can be built and deployed without restarting the server. See Hot Deployment for more information on how OpenShift uses a marker in the git repository to turn on this build style.

OTHER MARKERS

Adding marker files to .openshift/markers will have the following effects:
MarkerEffect
enable_jpda
Will enable the JPDA socket based transport on the java virtual machine running the Tomcat server. This enables you to remotely debug code running inside Tomcat.
skip_maven_build
Maven build step will be skipped
force_clean_build
Will start the build process by removing all non-essential Maven dependencies. Any current dependencies specified in your pom.xml file will then be re-downloaded.
java7
Will run Tomcat with Java7 if present. If no marker is present then the baseline Java version will be used (currently Java6)

Adding a Database to an Appliction

Find out how to add a database to your application by going to the Adding a Database guide.
You should only use environment variables to specify the connection parameters for your database. Using hard coded names, ports, or credentials limits the resusability of your app and can potentially break your app during OpenShift maintenance.
By default MySQL, Postgresql, and MongoDB have JNDI entries in your server.xml. As noted above, you can edit your server.xml, which allows you to delete or add other JNDI sources to your application. The syntax is standard syntax, there are no modifications needed for OpenShift, other than using the proper Environment Variables for the DB.

Configuring JVM properties

Environment variables can also be used to configure JVM properties. By setting the JAVA_OPTS_EXT environment variable, extra JAVA_OPTS can be added before the JVM is invoked. Here is an example setting the setting other garbage collection properties.
$ rhc env-set JAVA_OPTS_EXT="-XX:+PrintGCDetails  -Xloggc:$OPENSHIFT_LOG_DIR/gc.log" --app mytomcatapp
Please note that the startup parameters already set for Tomcat cannot be overwritten or changed. The parameters can be viewed via SSH’ing into your application gear using the following command:
$ ps axwwww | grep java

Next Steps

The best next step is to create an application using OpenShift.
Look at the application gallery and developer spotlight to see what other developers have created on OpenShift.
Browse our quickstarts and community cartridges to see other exciting technology you can use in your applications.
Finally, if at any point you have questions or issues, please visit the Help Center for a full list of options.

No hay comentarios:

Publicar un comentario