Trying to start/stop tomcat from my own cookbook

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar file
of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts my
application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using “execute” and in command passing the full
path of the script. The script does everything (extracts my application war
in particular location, removes some unwanted files from the extracted
war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can’t see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don’t want to use the existing tomcat cookbook, as I want to try it from
my location(where I have kept the tomcat.tar) also I want to use tomcat7.


Thanks and Regards,
Chandan

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar (this I
have placed somewhere in my other machine). After downloading I extract the
same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now I am simply
trying to start tomcat. I tried the below mentioned ways, but is not able
to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables at
the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables at
the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop the
tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts my
application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the full
path of the script. The script does everything (extracts my application war
in particular location, removes some unwanted files from the extracted
war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it from
my location(where I have kept the tomcat.tar) also I want to use tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

Specifying what error it runs I to will probably help folks help you. It's
standard troubleshooting question number one: what happens when you try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar (this
I have placed somewhere in my other machine). After downloading I extract
the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now I am
simply trying to start tomcat. I tried the below mentioned ways, but is not
able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables at
the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables at
the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop the
tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com <javascript:_e({}, 'cvml',
'cmaheshwari16@gmail.com');>> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts my
application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But now I
am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne
stormerider@gmail.comwrote:

Specifying what error it runs I to will probably help folks help you. It's
standard troubleshooting question number one: what happens when you try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar (this
I have placed somewhere in my other machine). After downloading I extract
the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now I am
simply trying to start tomcat. I tried the below mentioned ways, but is not
able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables at
the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop the
tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts
my application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <cmaheshwari16@gmail.com

wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But now
I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <stormerider@gmail.com

wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables at
the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh" BUT
IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts
my application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

Hi Morgan,

Appreciate your help.

I would log in as the user and check to make sure that those values are
set.
I logged in and when I print echo $JAVA_HOME I get the
value I set and so for others.So the .bashrc is loaded seems.
One more thing is inspite of setting these variables in .bashrc I am also
setting them in my script, from where I am calling tomcat/bin/startup.sh.

On Sun, May 12, 2013 at 6:29 PM, Morgan Blackthorne
stormerider@gmail.comwrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But now
I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts
my application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Chandan Maheshwari,
Cloud Softwate Engineer, Clogeny Technologies,
http://clogeny.com
(M) 0091-8956541752
Skype: chandan.maheshwari16

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need
or contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3) deploy
the file 4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:

This is a link to a definition I threw together for deploying Tomcat
apps in a dev env from Artifactory. Note that this is not a
production-ready pattern. It just runs, notices if there's a new war to
deploy and then stops the service, deletes the old war, and notifies the
"deploy" to run which basically copies in the new war and restarts the
service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with
Chef or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or the
Riot Games Artifact cookbook
(GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead
of re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values
are set. Also, if it's in .bashrc and startup.sh is using /bin/sh,
then they likely won't get loaded-- you might need to move it to
something like .profile (I forget exactly what startup file(s) sh
loads but I believe .bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari
<cmaheshwari16@gmail.com mailto:cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any
other location where I can check logs after logging into the newly
created instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set"
But now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.


On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne
<stormerider@gmail.com <mailto:stormerider@gmail.com>> wrote:

    Specifying what error it runs I to will probably help folks
    help you. It's standard troubleshooting question number one:
    what happens when you try?


    On Sunday, May 12, 2013, Chandan Maheshwari wrote:

        To be more specific, here is what all I have tried:

        I have my cookbook: where in my recipe, I am downloading
        tomcat.tar (this I have placed somewhere in my other
        machine). After downloading I extract the same tomcat.tar
        (suppose in location /home/ubuntu/tomcat). Now I am simply
        trying to start tomcat. I tried the below mentioned ways,
        but is not able to start/stop.

        1) Modified the ~/.bashrc file from my recipe to export
        JAVA_HOME, CATALINA_HOME,
        What I did is:

        In a recipe inside bash script simply added the
        environment variables at the end of ~/.bashrc and then ran
        source ~/.bashrc [ this works I can verify from ~/.bashrc
        file)

        Now using "execute" resource, ran
        "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT DO NOT START.*

        2) Modified the ~/.bashrc file from my recipe to export
        JAVA_HOME, CATALINA_HOME,
        What I did is:

        ran a bash script inside recipe to simply add the
        environment variables at the end of ~/.bashrc and then ran
        source ~/.bashrc

        Inside bash script resource, ran
        "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT DO NOT START.*

        3) Wrote a shell script and kept at the same location from
        where I am downloading tomcat.tar, downloaded the
        run_tomcat.sh on to the chef-client (using resource
        remote_file) and then using the "execute" resource running
        the run_tomcat.sh.
        Inside this run_tomcat.sh, I am exporting the environment
        variables and then running the
        "/home/ubuntu/tomcat/bin/startup.sh"
        *BUT IT DO NOT START.*

        4) Wrote a shell script and kept at the same location from
        where I am downloading tomcat.tar, downloaded the
        run_tomcat.sh on to the chef-client (using resource
        remote_file). Set environment variables using "environment
        resource" and run script using "execute" resource.
        Inside this run_tomcat.sh, running the
        "/home/ubuntu/tomcat/bin/startup.sh"
        *BUT IT DO NOT START.

        *
        For point 3 and 4 above the strange thing is that other
        commands inside run_tomcat.sh, like extracting war,
        deleting some directory from the extracted war executes.
        *BUT TOMCAT DOESN'T START UP.*

        I tried couple of other things also, but is not able to
        start or stop the tomcat.

        On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari
        <cmaheshwari16@gmail.com> wrote:


            Hi All,

            This may be a stupid or a silly question. But I am
            finding issues in getting it done.

            Basically I have wrote a cookbook, where I am simply
            downloading a tar file of tomcat with other stuff
            related to my app from some location.

            Then I am using some resources to untar it to define a
            specific folder structure onto my new instance created
            using knife ec2 plugin. (to be specific ubuntu)

            Now I have one shell script which basically stops the
            tomcat, extracts my application war in particular
            location, removes some unwanted files from the
            extracted war and then starts the tomcat back.

            I am executing this script using "execute" and in
            command passing the full path of the script. The
            script does everything (extracts my application war in
            particular location, removes some unwanted files from
            the extracted war), but it do not stops the tomcat and
            then starts it back.

            The chef-client runs successfully.

            Now when I login to the newly created instance, I
            can't see any tomcat logs. Moreover when I run the
            shell script manually (which I ran with cookbook
            also), it does everything and I can hit the URL to
            access my app.

            Any help is greatly appreciated.

            I don't want to use the existing tomcat cookbook, as I
            want to try it from my location(where I have kept the
            tomcat.tar) also I want to use tomcat7.

            -- 
            Thanks and Regards,
            Chandan




        -- 
        Regards,
        Chandan



    -- 
    --
    ~*~ StormeRider ~*~

    "Every world needs its heroes [...] They inspire us to be
    better than we are. And they protect from the darkness that's
    just around the corner."

    (from Smallville Season 6x1: "Zod")

    On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS




-- 
Regards,
Chandan

Also, if it's in .bashrc and startup.sh is using /bin/sh, then they likely
won't get loaded-- you might need to move it to something like .profile (I
forget exactly what startup file(s) sh loads but I believe .bashrc /
.bash_profile isn't included).
Oh then should I create .profile file (at this location "~/")
and export these variables in this file. But I checked tomcat-startup.sh
file and it do not include any of the above discussed files(.bashrc,
bash_profile or .profile)

Just for reference here is the tomcat/startup.sh:

Apache License, Version 2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.


Start Script for the CATALINA Server

$Id: startup.sh 1202062 2011-11-15 06:50:02Z mturk $


Better OS/400 detection: see Bugzilla 31132

os400=false
case "uname" in
OS400*) os400=true;;
esac

resolve links - $0 may be a softlink

PRG="$0"

while [ -h "$PRG" ] ; do
ls=ls -ld "$PRG"
link=expr "$ls" : '.*-> \(.*\)$'
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=dirname "$PRG"/"$link"
fi
done

PRGDIR=dirname "$PRG"
EXECUTABLE=catalina.sh

Check that target executable exists

if $os400; then

-x will Only work on the os400 if the files are:

1. owned by the user

2. owned by the PRIMARY group of the user

this will not work if the user belongs in secondary groups

eval
else
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
echo "Cannot find $PRGDIR/$EXECUTABLE"
echo "The file is absent or does not have execute permission"
echo "This file is needed to run this program"
exit 1
fi
fi

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

On Sun, May 12, 2013 at 6:29 PM, Morgan Blackthorne
stormerider@gmail.comwrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But now
I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts
my application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Chandan Maheshwari,
Cloud Softwate Engineer, Clogeny Technologies,
http://clogeny.com
(M) 0091-8956541752
Skype: chandan.maheshwari16

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification, So
Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am running.

(where I am extracting war and then starting the tomcat). Is this what you
asked me to do.

If you are going to make your script the authority, don't depend on Chef to
do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

               That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:

                   As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat apps
in a dev env from Artifactory. Note that this is not a production-ready
pattern. It just runs, notices if there's a new war to deploy and then
stops the service, deletes the old war, and notifies the "deploy" to run
which basically copies in the new war and restarts the service.

The important part of this to look at is notifications to stop, delete and
deploy. That pattern is really what you're looking to manage with Chef or
your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or the
Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But now
I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables and
    then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands inside
run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a tar
file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific folder
structure onto my new instance created using knife ec2 plugin. (to be
specific ubuntu)

Now I have one shell script which basically stops the tomcat, extracts
my application war in particular location, removes some unwanted files from
the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any tomcat
logs. Moreover when I run the shell script manually (which I ran with
cookbook also), it does everything and I can hit the URL to access my app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

Let's deal with getting your stuff working first, then we can worry
about making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running the
script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some
clarification, So Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am 

running. (where I am extracting war and then starting the tomcat). Is
this what you asked me to do.

If you are going to make your script the authority, don't depend on
Chef to do half the work, but ensure your script sources the files you
need or contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3) deploy
the file 4) start the tomcat app

               That is exactly what I need and am doing the same, 

through my default recipe I am running a script.sh(which I have
downloaded from remote location) Inside this script basically I am
extracting the war and then starting the tomcat, I have also exported
the variables in this script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be I 

don't find where and how the service will start from this. [Just to
make a note here I an not downloading/installing tomcat using the
community "tomcat cookbook". In my recipe I am downloading the tar of
tomcat and extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates <sascha.bates@gmail.com
mailto:sascha.bates@gmail.com> wrote:

The execute block will start your process as that user, but I'm
not positive that it will source the user environment files.  You
are much better off putting the JAVA_HOME, etc into your custom
script.

I'd put it like this:

If you are going to make your script the authority, don't depend
on Chef to do half the work, but ensure your script sources the
files you need or contains the environment variables it requires
OR
You might consider reconstructing your script into a chef
recipe/def that will 1) download a remote file, 2) stop the tomcat
app 3) deploy the file 4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger
service start stops from Chef.

Many of us in the community have wrestled with Java apps and would
be happy to help you refactor your recipe into something that
takes better advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:
---------------------------
Here is an example of the pattern I'm talking about:
https://gist.github.com/sbates/5563535
This is a link to a definition I threw together for deploying
Tomcat apps in a dev env from Artifactory.  Note that this is not
a production-ready pattern. It just runs, notices if there's a new
war to deploy and then stops the service, deletes the old war, and
notifies the "deploy" to run which basically copies in the new war
and restarts the service.

The important part of this to look at is notifications to stop,
delete and deploy.  That pattern is really what you're looking to
manage with Chef or your deploy script.

You can also manage your war file manipulations with tools like
Bryan Berry's Ark resource
(http://community.opscode.com/cookbooks/ark) or the Riot Games
Artifact cookbook (https://github.com/RiotGames/artifact-cookbook)
if you have complex needs.   I can also elaborate on why I wrote
some separate code instead of re-using community code in a
separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
https://github.com/bryanwb/jvmargs

I hope some of this helps and doesn't further confuse.

Sascha


Morgan Blackthorne wrote:
I would log in as the user and check to make sure that those
values are set. Also, if it's in .bashrc and startup.sh is using
/bin/sh, then they likely won't get loaded-- you might need to
move it to something like .profile (I forget exactly what startup
file(s) sh loads but I believe .bashrc / .bash_profile isn't
included).

--
~*~ StormeRider ~*~

"Every world needs its heroes [...] They inspire us to be better
than we are. And they protect from the darkness that's just
around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS


On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari
<cmaheshwari16@gmail.com <mailto:cmaheshwari16@gmail.com>> wrote:

    Thanks Morgan,

    I am afraid, but it doesn't give any error. The chef-client
    runs successfully and creates node and client onto my
    chef-server. Any other location where I can check logs after
    logging into the newly created instance.

    Also there are no logs for tomcat also.

    I did some troubleshooting initially to redirect output of
    command ..../tomcat/bin/startup.sh in a .txt file and saw
    that it says:
    "Neither JAVA_HOME nor JRE_HOME is set, need at least one to
    set" But now I am setting those in ~/.bashrc file also.

    Can you guide me what other trouble shooting I can do.


    On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne
    <stormerider@gmail.com <mailto:stormerider@gmail.com>> wrote:

        Specifying what error it runs I to will probably help
        folks help you. It's standard troubleshooting question
        number one: what happens when you try?


        On Sunday, May 12, 2013, Chandan Maheshwari wrote:

            To be more specific, here is what all I have tried:

            I have my cookbook: where in my recipe, I am
            downloading tomcat.tar (this I have placed somewhere
            in my other machine). After downloading I extract the
            same tomcat.tar (suppose in location
            /home/ubuntu/tomcat). Now I am simply trying to start
            tomcat. I tried the below mentioned ways, but is not
            able to start/stop.

            1) Modified the ~/.bashrc file from my recipe to
            export JAVA_HOME, CATALINA_HOME,
            What I did is:

            In a recipe inside bash script simply added the
            environment variables at the end of ~/.bashrc and
            then ran source ~/.bashrc [ this works I can verify
            from ~/.bashrc file)

            Now using "execute" resource, ran
            "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT DO NOT
            START.*

            2) Modified the ~/.bashrc file from my recipe to
            export JAVA_HOME, CATALINA_HOME,
            What I did is:

            ran a bash script inside recipe to simply add the
            environment variables at the end of ~/.bashrc and
            then ran source ~/.bashrc

            Inside bash script resource, ran
            "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT DO NOT
            START.*

            3) Wrote a shell script and kept at the same location
            from where I am downloading tomcat.tar, downloaded
            the run_tomcat.sh on to the chef-client (using
            resource remote_file) and then using the "execute"
            resource running the run_tomcat.sh.
            Inside this run_tomcat.sh, I am exporting the
            environment variables and then running the
            "/home/ubuntu/tomcat/bin/startup.sh"
            *BUT IT DO NOT START.*

            4) Wrote a shell script and kept at the same location
            from where I am downloading tomcat.tar, downloaded
            the run_tomcat.sh on to the chef-client (using
            resource remote_file). Set environment variables
            using "environment resource" and run script using
            "execute" resource.
            Inside this run_tomcat.sh, running the
            "/home/ubuntu/tomcat/bin/startup.sh"
            *BUT IT DO NOT START.

            *
            For point 3 and 4 above the strange thing is that
            other commands inside run_tomcat.sh, like extracting
            war, deleting some directory from the extracted war
            executes. *BUT TOMCAT DOESN'T START UP.*

            I tried couple of other things also, but is not able
            to start or stop the tomcat.

            On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari
            <cmaheshwari16@gmail.com> wrote:


                Hi All,

                This may be a stupid or a silly question. But I
                am finding issues in getting it done.

                Basically I have wrote a cookbook, where I am
                simply downloading a tar file of tomcat with
                other stuff related to my app from some location.

                Then I am using some resources to untar it to
                define a specific folder structure onto my new
                instance created using knife ec2 plugin. (to be
                specific ubuntu)

                Now I have one shell script which basically stops
                the tomcat, extracts my application war in
                particular location, removes some unwanted files
                from the extracted war and then starts the tomcat
                back.

                I am executing this script using "execute" and in
                command passing the full path of the script. The
                script does everything (extracts my application
                war in particular location, removes some unwanted
                files from the extracted war), but it do not
                stops the tomcat and then starts it back.

                The chef-client runs successfully.

                Now when I login to the newly created instance, I
                can't see any tomcat logs. Moreover when I run
                the shell script manually (which I ran with
                cookbook also), it does everything and I can hit
                the URL to access my app.

                Any help is greatly appreciated.

                I don't want to use the existing tomcat cookbook,
                as I want to try it from my location(where I have
                kept the tomcat.tar) also I want to use tomcat7.

                -- 
                Thanks and Regards,
                Chandan




            -- 
            Regards,
            Chandan



        -- 
        --
        ~*~ StormeRider ~*~

        "Every world needs its heroes [...] They inspire us to be
        better than we are. And they protect from the darkness
        that's just around the corner."

        (from Smallville Season 6x1: "Zod")

        On why I hate the phrase "that's so lame"...
        http://bit.ly/Ps3uSS




    -- 
    Regards,
    Chandan

--
Regards,
Chandan

Have you considered wrapping the tomcat install with the java wrapper (
tanukisoftware.com). This scenario you describe is the exact reason I use
it. It sets up an environment for you then launches the jvm according to
all the params you define in it's config. This simplifies the chef part of
the equation and makes the whole java invocation part less hairy while
providing you a consistent pattern to the configuration of java
applications.
On 2013-05-12 11:33 AM, "Chandan Maheshwari" cmaheshwari16@gmail.com
wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification, So
Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am running.

(where I am extracting war and then starting the tomcat). Is this what you
asked me to do.

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

               That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat apps
in a dev env from Artifactory. Note that this is not a production-ready
pattern. It just runs, notices if there's a new war to deploy and then
stops the service, deletes the old war, and notifies the "deploy" to run
which basically copies in the new war and restarts the service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with Chef
or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or the
Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

.bashrc, .bash_profile, and .profile are all automatically sourced when you
run a shell (the first two apply specifically to bash, the latter applies
to sh/bash equally, IIRC). They won't be listed in the script because it's
a function of the shell itself, not the script that uses said shell.

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 6:48 AM, Chandan Maheshwari <
chandan.maheshwari@clogeny.com> wrote:

Also, if it's in .bashrc and startup.sh is using /bin/sh, then they likely
won't get loaded-- you might need to move it to something like .profile (I
forget exactly what startup file(s) sh loads but I believe .bashrc /
.bash_profile isn't included).
Oh then should I create .profile file (at this location
"~/") and export these variables in this file. But I checked
tomcat-startup.sh file and it do not include any of the above discussed
files(.bashrc, bash_profile or .profile)

Just for reference here is the tomcat/startup.sh:

Apache License, Version 2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.


Start Script for the CATALINA Server

$Id: startup.sh 1202062 2011-11-15 06:50:02Z mturk $


Better OS/400 detection: see Bugzilla 31132

os400=false
case "uname" in
OS400*) os400=true;;
esac

resolve links - $0 may be a softlink

PRG="$0"

while [ -h "$PRG" ] ; do
ls=ls -ld "$PRG"
link=expr "$ls" : '.*-> \(.*\)$'
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=dirname "$PRG"/"$link"
fi
done

PRGDIR=dirname "$PRG"
EXECUTABLE=catalina.sh

Check that target executable exists

if $os400; then

-x will Only work on the os400 if the files are:

1. owned by the user

2. owned by the PRIMARY group of the user

this will not work if the user belongs in secondary groups

eval
else
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
echo "Cannot find $PRGDIR/$EXECUTABLE"
echo "The file is absent or does not have execute permission"
echo "This file is needed to run this program"
exit 1
fi
fi

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

On Sun, May 12, 2013 at 6:29 PM, Morgan Blackthorne <stormerider@gmail.com

wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Chandan Maheshwari,
Cloud Softwate Engineer, Clogeny Technologies,
http://clogeny.com
(M) 0091-8956541752
Skype: chandan.maheshwari16

I tend to agree that this is likely the problem. Also, if the files are
sitting underneath /home/ubuntu why are you using sudo to start/stop it in
the first place... shouldn't you remove the sudo command and run the script
to redeploy the app as the ubuntu user? Or, approaching it from the
opposite perspective, if you're going to run it as root, why locate it
under /home/ubuntu instead of someplace like /opt?

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 8:51 AM, Sascha Bates sascha.bates@gmail.comwrote:

Let's deal with getting your stuff working first, then we can worry about
making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running the
script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification, So
Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am running.

(where I am extracting war and then starting the tomcat). Is this what you
asked me to do.

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

               That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat apps
in a dev env from Artifactory. Note that this is not a production-ready
pattern. It just runs, notices if there's a new war to deploy and then
stops the service, deletes the old war, and notifies the "deploy" to run
which basically copies in the new war and restarts the service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with Chef
or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or the
Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

Hi Sascha,

I tried with both users. Moreover As I mentioned I am again setting the
environment variable inside my custom script also. Just to make in light,
if it missed, in the above code snippet "#environment 'JAVA_HOME' =>
"#{extract_path_java}/jdk1.6.0_45"" (this is commented).

On Sun, May 12, 2013 at 9:21 PM, Sascha Bates sascha.bates@gmail.comwrote:

Let's deal with getting your stuff working first, then we can worry about
making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running the
script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification, So
Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am running.

(where I am extracting war and then starting the tomcat). Is this what you
asked me to do.

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

               That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat apps
in a dev env from Artifactory. Note that this is not a production-ready
pattern. It just runs, notices if there's a new war to deploy and then
stops the service, deletes the old war, and notifies the "deploy" to run
which basically copies in the new war and restarts the service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with Chef
or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or the
Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing the
full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try it
from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

--
Regards,
Chandan

Also, if the files are sitting underneath /home/ubuntu why are you using
sudo to start/stop it in the first place...
I tried without sudo also, (may be the last attempt I
tried was with sudo, that's why the copy pasted code is having sudo, but to
make sure it do not work without sudo also)

Or, approaching it from the opposite perspective, if you're going to run it
as root, why locate it under /home/ubuntu instead of someplace like /opt?
I tried creating my folder structure in /d00/......,
and then tried to run the script with sudo, still everything works except
the start/stop of tomcat.

On Sun, May 12, 2013 at 10:14 PM, Morgan Blackthorne
stormerider@gmail.comwrote:

I tend to agree that this is likely the problem. Also, if the files are
sitting underneath /home/ubuntu why are you using sudo to start/stop it in
the first place... shouldn't you remove the sudo command and run the script
to redeploy the app as the ubuntu user? Or, approaching it from the
opposite perspective, if you're going to run it as root, why locate it
under /home/ubuntu instead of someplace like /opt?

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 8:51 AM, Sascha Bates sascha.bates@gmail.comwrote:

Let's deal with getting your stuff working first, then we can worry about
making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running the
script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification,
So Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am running.

(where I am extracting war and then starting the tomcat). Is this what you
asked me to do.

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

               That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3) deploy the
file 4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat
apps in a dev env from Artifactory. Note that this is not a
production-ready pattern. It just runs, notices if there's a new war to
deploy and then stops the service, deletes the old war, and notifies the
"deploy" to run which basically copies in the new war and restarts the
service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with Chef
or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or
the Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or stop
the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing
the full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try
it from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

--
Regards,
Chandan

Does this work when you invoke it at the command line without Chef?

Chandan Maheshwari wrote:

Also, if the files are sitting underneath /home/ubuntu why are you
using sudo to start/stop it in the first place...
I tried without sudo also, (may be the last attempt
I tried was with sudo, that's why the copy pasted code is having sudo,
but to make sure it do not work without sudo also)

Or, approaching it from the opposite perspective, if you're going to
run it as root, why locate it under /home/ubuntu instead of someplace
like /opt?
I tried creating my folder structure in
/d00/......, and then tried to run the script with sudo, still
everything works except the start/stop of tomcat.

On Sun, May 12, 2013 at 10:14 PM, Morgan Blackthorne
<stormerider@gmail.com mailto:stormerider@gmail.com> wrote:

I tend to agree that this is likely the problem. Also, if the
files are sitting underneath /home/ubuntu why are you using sudo
to start/stop it in the first place... shouldn't you remove the
sudo command and run the script to redeploy the app as the ubuntu
user? Or, approaching it from the opposite perspective, if you're
going to run it as root, why locate it under /home/ubuntu instead
of someplace like /opt?

--
~*~ StormeRider ~*~

"Every world needs its heroes [...] They inspire us to be better
than we are. And they protect from the darkness that's just around
the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS


On Sun, May 12, 2013 at 8:51 AM, Sascha Bates
<sascha.bates@gmail.com <mailto:sascha.bates@gmail.com>> wrote:

    Let's deal with getting your stuff working first, then we can
    worry about making it pretty with chef.

    I am guessing this is your problem:

    export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
    *sudo /home/ubuntu/scripts/apps_stop.sh >
    /home/ubuntu/scripts/stop.txt*

    You are exporting your JAVA home as the ubuntu user and then
    running the script as root.

    Look: As the vagrant user I export my JAVA_HOME and I can see
    it in my environment variables, but if I then check with sudo,
    it's not there.
    vagrant@saschabX-vagrant:~$ env|grep JAVA
    vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
    vagrant@saschabX-vagrant:~$ env|grep JAVA
    JAVA_HOME=/opt/java/myjava <<<<--------------
    vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
    vagrant@saschabX-vagrant:~$






    Chandan Maheshwari wrote:
    Hi Sascha,

    Thanks for the great elaboration, but I still needs some
    clarification, So Sorry for this.

    The execute block will start your process as that user, but
    I'm not positive that it will source the user environment
    files.  You are much better off putting the JAVA_HOME, etc
    into your custom script.

                   I have exported JAVA_HOME, etc in the script I
    am running. (where I am extracting war and then starting the
    tomcat). Is this what you asked me to do.


    If you are going to make your script the authority, don't
    depend on Chef to do half the work, but ensure your script
    sources the files you need or contains the environment
    variables it requires
    OR
    You might consider reconstructing your script into a chef
    recipe/def that will 1) download a remote file, 2) stop the
    tomcat app 3) deploy the file 4) start the tomcat app

                       That is exactly what I need and am doing
    the same, through my default recipe I am running a
    script.sh(which I have downloaded from remote location)
    Inside this script basically I am extracting the war and then
    starting the tomcat, I have also exported the variables in
    this script. Here is the snippet:

    execute "redeploy_apps" do
    cwd "#{extract_path_scripts}"
    user "ubuntu"
    #environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
    command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
    end

    NOTE I tried with root user also.

    In the redeploy_apps_script I have :

    export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
    *sudo /home/ubuntu/scripts/apps_stop.sh >
    /home/ubuntu/scripts/stop.txt*
    echo "Stopping APP Please Wait"
    sleep 30
    rm -rf /home/ubuntu/tomcat/logs/*
    rm -rf /home/ubuntu/tomcat/work/*

    rm -rf /home/ubuntu/tomcat/webapps/apps
    mkdir  /home/ubuntu/tomcat/webapps/apps

    rm -rf /home/ubuntu/tomcat/webapps/static
    mkdir  /home/ubuntu/tomcat/webapps/static

    cd /home/ubuntu/tomcat/webapps/apps
    echo "Extracting War"
    /home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

    cd /home/ubuntu/tomcat/webapps/static
    /home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

    *sudo /home/ubuntu/scripts/apps_start.sh >
    /home/ubuntu/scripts/start.sh
    *



    Except the lines in bold everything works.

    You might consider reconstructing your script into a chef
    recipe/def that will 1) download a remote file, 2) stop the
    tomcat app 3)
    deploy the file 4) start the tomcat app

                    Would appreciate a lot if you can help me in
    this.

    Here is an example of the pattern I'm talking about:
    https://gist.github.com/sbates/5563535

                           As I dont have that much experience so
    may be I don't find where and how the service will start from
    this. [Just to make a note here I an not
    downloading/installing tomcat using the community "tomcat
    cookbook". In my recipe I am downloading the tar of tomcat
    and extracting it.

    Sorry If the above queries are too basic, please bare it.


    On Sun, May 12, 2013 at 7:15 PM, Sascha Bates
    <sascha.bates@gmail.com <mailto:sascha.bates@gmail.com>> wrote:

        The execute block will start your process as that user,
        but I'm not positive that it will source the user
        environment files.  You are much better off putting the
        JAVA_HOME, etc into your custom script.

        I'd put it like this:

        If you are going to make your script the authority, don't
        depend on Chef to do half the work, but ensure your
        script sources the files you need or contains the
        environment variables it requires
        OR
        You might consider reconstructing your script into a chef
        recipe/def that will 1) download a remote file, 2) stop
        the tomcat app 3) deploy the file 4) start the tomcat app

        In this fashion, you can set up tomcat as a service and
        trigger service start stops from Chef.

        Many of us in the community have wrestled with Java apps
        and would be happy to help you refactor your recipe into
        something that takes better advantage of Chef's primitives.

        tl;dr discussion about tomcat deploy strategies:
        ---------------------------
        Here is an example of the pattern I'm talking about:
        https://gist.github.com/sbates/5563535
        This is a link to a definition I threw together for
        deploying Tomcat apps in a dev env from Artifactory. 
        Note that this is not a production-ready pattern. It just
        runs, notices if there's a new war to deploy and then
        stops the service, deletes the old war, and notifies the
        "deploy" to run which basically copies in the new war and
        restarts the service.

        The important part of this to look at is notifications to
        stop, delete and deploy.  That pattern is really what
        you're looking to manage with Chef or your deploy script.

        You can also manage your war file manipulations with
        tools like Bryan Berry's Ark resource
        (http://community.opscode.com/cookbooks/ark) or the Riot
        Games Artifact cookbook
        (https://github.com/RiotGames/artifact-cookbook) if you
        have complex needs.   I can also elaborate on why I wrote
        some separate code instead of re-using community code in
        a separate email if anyone wants.

        Bryan has also written a library for managing JVM Args:
        https://github.com/bryanwb/jvmargs

        I hope some of this helps and doesn't further confuse.

        Sascha


        Morgan Blackthorne wrote:
        I would log in as the user and check to make sure that
        those values are set. Also, if it's in .bashrc and
        startup.sh is using /bin/sh, then they likely won't get
        loaded-- you might need to move it to something like
        .profile (I forget exactly what startup file(s) sh loads
        but I believe .bashrc / .bash_profile isn't included).

        --
        ~*~ StormeRider ~*~

        "Every world needs its heroes [...] They inspire us to
        be better than we are. And they protect from the
        darkness that's just around the corner."

        (from Smallville Season 6x1: "Zod")

        On why I hate the phrase "that's so lame"...
        http://bit.ly/Ps3uSS


        On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari
        <cmaheshwari16@gmail.com
        <mailto:cmaheshwari16@gmail.com>> wrote:

            Thanks Morgan,

            I am afraid, but it doesn't give any error. The
            chef-client runs successfully and creates node and
            client onto my chef-server. Any other location where
            I can check logs after logging into the newly
            created instance.

            Also there are no logs for tomcat also.

            I did some troubleshooting initially to redirect
            output of command ..../tomcat/bin/startup.sh in a
            .txt file and saw that it says:
            "Neither JAVA_HOME nor JRE_HOME is set, need at
            least one to set" But now I am setting those in
            ~/.bashrc file also.

            Can you guide me what other trouble shooting I can do.


            On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne
            <stormerider@gmail.com
            <mailto:stormerider@gmail.com>> wrote:

                Specifying what error it runs I to will probably
                help folks help you. It's standard
                troubleshooting question number one: what
                happens when you try?


                On Sunday, May 12, 2013, Chandan Maheshwari wrote:

                    To be more specific, here is what all I have
                    tried:

                    I have my cookbook: where in my recipe, I am
                    downloading tomcat.tar (this I have placed
                    somewhere in my other machine). After
                    downloading I extract the same tomcat.tar
                    (suppose in location /home/ubuntu/tomcat).
                    Now I am simply trying to start tomcat. I
                    tried the below mentioned ways, but is not
                    able to start/stop.

                    1) Modified the ~/.bashrc file from my
                    recipe to export JAVA_HOME, CATALINA_HOME,
                    What I did is:

                    In a recipe inside bash script simply added
                    the environment variables at the end of
                    ~/.bashrc and then ran source ~/.bashrc [
                    this works I can verify from ~/.bashrc file)

                    Now using "execute" resource, ran
                    "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT
                    DO NOT START.*

                    2) Modified the ~/.bashrc file from my
                    recipe to export JAVA_HOME, CATALINA_HOME,
                    What I did is:

                    ran a bash script inside recipe to simply
                    add the environment variables at the end of
                    ~/.bashrc and then ran source ~/.bashrc

                    Inside bash script resource, ran
                    "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT
                    DO NOT START.*

                    3) Wrote a shell script and kept at the same
                    location from where I am downloading
                    tomcat.tar, downloaded the run_tomcat.sh on
                    to the chef-client (using resource
                    remote_file) and then using the "execute"
                    resource running the run_tomcat.sh.
                    Inside this run_tomcat.sh, I am exporting
                    the environment variables and then running
                    the "/home/ubuntu/tomcat/bin/startup.sh"
                    *BUT IT DO NOT START.*

                    4) Wrote a shell script and kept at the same
                    location from where I am downloading
                    tomcat.tar, downloaded the run_tomcat.sh on
                    to the chef-client (using resource
                    remote_file). Set environment variables
                    using "environment resource" and run script
                    using "execute" resource.
                    Inside this run_tomcat.sh, running the
                    "/home/ubuntu/tomcat/bin/startup.sh"
                    *BUT IT DO NOT START.

                    *
                    For point 3 and 4 above the strange thing is
                    that other commands inside run_tomcat.sh,
                    like extracting war, deleting some directory
                    from the extracted war executes. *BUT TOMCAT
                    DOESN'T START UP.*

                    I tried couple of other things also, but is
                    not able to start or stop the tomcat.

                    On Fri, May 10, 2013 at 11:00 PM, Chandan
                    Maheshwari <cmaheshwari16@gmail.com> wrote:


                        Hi All,

                        This may be a stupid or a silly
                        question. But I am finding issues in
                        getting it done.

                        Basically I have wrote a cookbook, where
                        I am simply downloading a tar file of
                        tomcat with other stuff related to my
                        app from some location.

                        Then I am using some resources to untar
                        it to define a specific folder structure
                        onto my new instance created using knife
                        ec2 plugin. (to be specific ubuntu)

                        Now I have one shell script which
                        basically stops the tomcat, extracts my
                        application war in particular location,
                        removes some unwanted files from the
                        extracted war and then starts the tomcat
                        back.

                        I am executing this script using
                        "execute" and in command passing the
                        full path of the script. The script does
                        everything (extracts my application war
                        in particular location, removes some
                        unwanted files from the extracted war),
                        but it do not stops the tomcat and then
                        starts it back.

                        The chef-client runs successfully.

                        Now when I login to the newly created
                        instance, I can't see any tomcat logs.
                        Moreover when I run the shell script
                        manually (which I ran with cookbook
                        also), it does everything and I can hit
                        the URL to access my app.

                        Any help is greatly appreciated.

                        I don't want to use the existing tomcat
                        cookbook, as I want to try it from my
                        location(where I have kept the
                        tomcat.tar) also I want to use tomcat7.

                        -- 
                        Thanks and Regards,
                        Chandan




                    -- 
                    Regards,
                    Chandan



                -- 
                --
                ~*~ StormeRider ~*~

                "Every world needs its heroes [...] They inspire
                us to be better than we are. And they protect
                from the darkness that's just around the corner."

                (from Smallville Season 6x1: "Zod")

                On why I hate the phrase "that's so lame"...
                http://bit.ly/Ps3uSS




            -- 
            Regards,
            Chandan
    -- 
    Regards,
    Chandan

--
Regards,
Chandan

Yes my custom script works if I run it manually through command line on the
instance.

Also as I mentioned earlier, when I apply my cookbooks, the instance on ec2
gets created(ubuntu) and the chef-client exits gracefully. But the tomcat
doesn't starts. On the same node if now I ssh and then start tomcat
manuallly or by the custom script it starts and I can access my application
through URL

On Sun, May 12, 2013 at 11:20 PM, Sascha Bates sascha.bates@gmail.comwrote:

Does this work when you invoke it at the command line without Chef?

Chandan Maheshwari wrote:

Also, if the files are sitting underneath /home/ubuntu why are you using
sudo to start/stop it in the first place...
I tried without sudo also, (may be the last attempt I
tried was with sudo, that's why the copy pasted code is having sudo, but to
make sure it do not work without sudo also)

Or, approaching it from the opposite perspective, if you're going to run
it as root, why locate it under /home/ubuntu instead of someplace like /opt?
I tried creating my folder structure in
/d00/......, and then tried to run the script with sudo, still everything
works except the start/stop of tomcat.

On Sun, May 12, 2013 at 10:14 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

I tend to agree that this is likely the problem. Also, if the files are
sitting underneath /home/ubuntu why are you using sudo to start/stop it in
the first place... shouldn't you remove the sudo command and run the script
to redeploy the app as the ubuntu user? Or, approaching it from the
opposite perspective, if you're going to run it as root, why locate it
under /home/ubuntu instead of someplace like /opt?

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 8:51 AM, Sascha Bates sascha.bates@gmail.comwrote:

Let's deal with getting your stuff working first, then we can worry
about making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running the
script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification,
So Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am

running. (where I am extracting war and then starting the tomcat). Is this
what you asked me to do.

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3) deploy the
file 4) start the tomcat app

               That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on
Chef to do half the work, but ensure your script sources the files you need
or contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3) deploy the
file 4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat
apps in a dev env from Artifactory. Note that this is not a
production-ready pattern. It just runs, notices if there's a new war to
deploy and then stops the service, deletes the old war, and notifies the
"deploy" to run which basically copies in the new war and restarts the
service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with Chef
or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or
the Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading tomcat.tar
(this I have placed somewhere in my other machine). After downloading I
extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now
I am simply trying to start tomcat. I tried the below mentioned ways, but
is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc [ this
works I can verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I
    am downloading tomcat.tar, downloaded the run_tomcat.sh on to the
    chef-client (using resource remote_file) and then using the "execute"
    resource running the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I
    am downloading tomcat.tar, downloaded the run_tomcat.sh on to the
    chef-client (using resource remote_file). Set environment variables using
    "environment resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or
stop the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues
in getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing
the full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try
it from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

--
Regards,
Chandan

--
Regards,
Chandan

I'm not sure how much we can get out of email troubleshooting at this
point. Can you check your cookbook into a github repo or gist
(https://gist.github.com/) the relevant files, meaning your script, the
recipe and any other cookbook files you may have? It will be easier to
look at your code in that medium than email snippets.

Chandan Maheshwari wrote:

Yes my custom script works if I run it manually through command line
on the instance.

Also as I mentioned earlier, when I apply my cookbooks, the instance
on ec2 gets created(ubuntu) and the chef-client exits gracefully. But
the tomcat doesn't starts. On the same node if now I ssh and then
start tomcat manuallly or by the custom script it starts and I can
access my application through URL

On Sun, May 12, 2013 at 11:20 PM, Sascha Bates <sascha.bates@gmail.com
mailto:sascha.bates@gmail.com> wrote:

Does this work when you invoke it at the command line without Chef?

Chandan Maheshwari wrote:
Also, if the files are sitting underneath /home/ubuntu why are
you using sudo to start/stop it in the first place...
                  I tried without sudo also, (may be the last
attempt I tried was with sudo, that's why the copy pasted code is
having sudo, but to make sure it do not work without sudo also)

Or, approaching it from the opposite perspective, if you're going
to run it as root, why locate it under /home/ubuntu instead of
someplace like /opt?
                       I tried creating my folder structure in
/d00/......, and then tried to run the script with sudo, still
everything works except the start/stop of tomcat.


On Sun, May 12, 2013 at 10:14 PM, Morgan Blackthorne
<stormerider@gmail.com <mailto:stormerider@gmail.com>> wrote:

    I tend to agree that this is likely the problem. Also, if the
    files are sitting underneath /home/ubuntu why are you using
    sudo to start/stop it in the first place... shouldn't you
    remove the sudo command and run the script to redeploy the
    app as the ubuntu user? Or, approaching it from the opposite
    perspective, if you're going to run it as root, why locate it
    under /home/ubuntu instead of someplace like /opt?

    --
    ~*~ StormeRider ~*~

    "Every world needs its heroes [...] They inspire us to be
    better than we are. And they protect from the darkness that's
    just around the corner."

    (from Smallville Season 6x1: "Zod")

    On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS


    On Sun, May 12, 2013 at 8:51 AM, Sascha Bates
    <sascha.bates@gmail.com <mailto:sascha.bates@gmail.com>> wrote:

        Let's deal with getting your stuff working first, then we
        can worry about making it pretty with chef.

        I am guessing this is your problem:

        export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
        *sudo /home/ubuntu/scripts/apps_stop.sh >
        /home/ubuntu/scripts/stop.txt*

        You are exporting your JAVA home as the ubuntu user and
        then running the script as root.

        Look: As the vagrant user I export my JAVA_HOME and I can
        see it in my environment variables, but if I then check
        with sudo, it's not there.
        vagrant@saschabX-vagrant:~$ env|grep JAVA
        vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
        vagrant@saschabX-vagrant:~$ env|grep JAVA
        JAVA_HOME=/opt/java/myjava <<<<--------------
        vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
        vagrant@saschabX-vagrant:~$






        Chandan Maheshwari wrote:
        Hi Sascha,

        Thanks for the great elaboration, but I still needs some
        clarification, So Sorry for this.

        The execute block will start your process as that user,
        but I'm not positive that it will source the user
        environment files.  You are much better off putting the
        JAVA_HOME, etc into your custom script.

                       I have exported JAVA_HOME, etc in the
        script I am running. (where I am extracting war and then
        starting the tomcat). Is this what you asked me to do.


        If you are going to make your script the authority,
        don't depend on Chef to do half the work, but ensure
        your script sources the files you need or contains the
        environment variables it requires
        OR
        You might consider reconstructing your script into a
        chef recipe/def that will 1) download a remote file, 2)
        stop the tomcat app 3) deploy the file 4) start the
        tomcat app

                           That is exactly what I need and am
        doing the same, through my default recipe I am running a
        script.sh(which I have downloaded from remote location)
        Inside this script basically I am extracting the war and
        then starting the tomcat, I have also exported the
        variables in this script. Here is the snippet:

        execute "redeploy_apps" do
        cwd "#{extract_path_scripts}"
        user "ubuntu"
        #environment 'JAVA_HOME' =>
        "#{extract_path_java}/jdk1.6.0_45"
        command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
        end

        NOTE I tried with root user also.

        In the redeploy_apps_script I have :

        export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
        *sudo /home/ubuntu/scripts/apps_stop.sh >
        /home/ubuntu/scripts/stop.txt*
        echo "Stopping APP Please Wait"
        sleep 30
        rm -rf /home/ubuntu/tomcat/logs/*
        rm -rf /home/ubuntu/tomcat/work/*

        rm -rf /home/ubuntu/tomcat/webapps/apps
        mkdir  /home/ubuntu/tomcat/webapps/apps

        rm -rf /home/ubuntu/tomcat/webapps/static
        mkdir  /home/ubuntu/tomcat/webapps/static

        cd /home/ubuntu/tomcat/webapps/apps
        echo "Extracting War"
        /home/ubuntu/jdk1.6.0_45/bin/jar -xf
        /home/ubuntu/war/apps.war

        cd /home/ubuntu/tomcat/webapps/static
        /home/ubuntu/jdk1.6.0_45/bin/jar -xf
        /home/ubuntu/war/apps.war

        *sudo /home/ubuntu/scripts/apps_start.sh >
        /home/ubuntu/scripts/start.sh
        *



        Except the lines in bold everything works.

        You might consider reconstructing your script into a
        chef recipe/def that will 1) download a remote file, 2)
        stop the tomcat app 3)
        deploy the file 4) start the tomcat app

                        Would appreciate a lot if you can help
        me in this.

        Here is an example of the pattern I'm talking about:
        https://gist.github.com/sbates/5563535

                               As I dont have that much
        experience so may be I don't find where and how the
        service will start from this. [Just to make a note here
        I an not downloading/installing tomcat using the
        community "tomcat cookbook". In my recipe I am
        downloading the tar of tomcat and extracting it.

        Sorry If the above queries are too basic, please bare it.


        On Sun, May 12, 2013 at 7:15 PM, Sascha Bates
        <sascha.bates@gmail.com <mailto:sascha.bates@gmail.com>>
        wrote:

            The execute block will start your process as that
            user, but I'm not positive that it will source the
            user environment files.  You are much better off
            putting the JAVA_HOME, etc into your custom script.

            I'd put it like this:

            If you are going to make your script the authority,
            don't depend on Chef to do half the work, but ensure
            your script sources the files you need or contains
            the environment variables it requires
            OR
            You might consider reconstructing your script into a
            chef recipe/def that will 1) download a remote file,
            2) stop the tomcat app 3) deploy the file 4) start
            the tomcat app

            In this fashion, you can set up tomcat as a service
            and trigger service start stops from Chef.

            Many of us in the community have wrestled with Java
            apps and would be happy to help you refactor your
            recipe into something that takes better advantage of
            Chef's primitives.

            tl;dr discussion about tomcat deploy strategies:
            ---------------------------
            Here is an example of the pattern I'm talking about:
            https://gist.github.com/sbates/5563535
            This is a link to a definition I threw together for
            deploying Tomcat apps in a dev env from
            Artifactory.  Note that this is not a
            production-ready pattern. It just runs, notices if
            there's a new war to deploy and then stops the
            service, deletes the old war, and notifies the
            "deploy" to run which basically copies in the new
            war and restarts the service.

            The important part of this to look at is
            notifications to stop, delete and deploy.  That
            pattern is really what you're looking to manage with
            Chef or your deploy script.

            You can also manage your war file manipulations with
            tools like Bryan Berry's Ark resource
            (http://community.opscode.com/cookbooks/ark) or the
            Riot Games Artifact cookbook
            (https://github.com/RiotGames/artifact-cookbook) if
            you have complex needs.   I can also elaborate on
            why I wrote some separate code instead of re-using
            community code in a separate email if anyone wants.

            Bryan has also written a library for managing JVM
            Args: https://github.com/bryanwb/jvmargs

            I hope some of this helps and doesn't further confuse.

            Sascha


            Morgan Blackthorne wrote:
            I would log in as the user and check to make sure
            that those values are set. Also, if it's in .bashrc
            and startup.sh is using /bin/sh, then they likely
            won't get loaded-- you might need to move it to
            something like .profile (I forget exactly what
            startup file(s) sh loads but I believe .bashrc /
            .bash_profile isn't included).

            --
            ~*~ StormeRider ~*~

            "Every world needs its heroes [...] They inspire us
            to be better than we are. And they protect from the
            darkness that's just around the corner."

            (from Smallville Season 6x1: "Zod")

            On why I hate the phrase "that's so lame"...
            http://bit.ly/Ps3uSS


            On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari
            <cmaheshwari16@gmail.com
            <mailto:cmaheshwari16@gmail.com>> wrote:

                Thanks Morgan,

                I am afraid, but it doesn't give any error. The
                chef-client runs successfully and creates node
                and client onto my chef-server. Any other
                location where I can check logs after logging
                into the newly created instance.

                Also there are no logs for tomcat also.

                I did some troubleshooting initially to
                redirect output of command
                ..../tomcat/bin/startup.sh in a .txt file and
                saw that it says:
                "Neither JAVA_HOME nor JRE_HOME is set, need at
                least one to set" But now I am setting those in
                ~/.bashrc file also.

                Can you guide me what other trouble shooting I
                can do.


                On Sun, May 12, 2013 at 5:00 PM, Morgan
                Blackthorne <stormerider@gmail.com
                <mailto:stormerider@gmail.com>> wrote:

                    Specifying what error it runs I to will
                    probably help folks help you. It's standard
                    troubleshooting question number one: what
                    happens when you try?


                    On Sunday, May 12, 2013, Chandan Maheshwari
                    wrote:

                        To be more specific, here is what all I
                        have tried:

                        I have my cookbook: where in my recipe,
                        I am downloading tomcat.tar (this I
                        have placed somewhere in my other
                        machine). After downloading I extract
                        the same tomcat.tar (suppose in
                        location /home/ubuntu/tomcat). Now I am
                        simply trying to start tomcat. I tried
                        the below mentioned ways, but is not
                        able to start/stop.

                        1) Modified the ~/.bashrc file from my
                        recipe to export JAVA_HOME, CATALINA_HOME,
                        What I did is:

                        In a recipe inside bash script simply
                        added the environment variables at the
                        end of ~/.bashrc and then ran source
                        ~/.bashrc [ this works I can verify
                        from ~/.bashrc file)

                        Now using "execute" resource, ran
                        "/home/ubuntu/tomcat/bin/startup.sh"
                        *BUT IT DO NOT START.*

                        2) Modified the ~/.bashrc file from my
                        recipe to export JAVA_HOME, CATALINA_HOME,
                        What I did is:

                        ran a bash script inside recipe to
                        simply add the environment variables at
                        the end of ~/.bashrc and then ran
                        source ~/.bashrc

                        Inside bash script resource, ran
                        "/home/ubuntu/tomcat/bin/startup.sh"
                        *BUT IT DO NOT START.*

                        3) Wrote a shell script and kept at the
                        same location from where I am
                        downloading tomcat.tar, downloaded the
                        run_tomcat.sh on to the chef-client
                        (using resource remote_file) and then
                        using the "execute" resource running
                        the run_tomcat.sh.
                        Inside this run_tomcat.sh, I am
                        exporting the environment variables and
                        then running the
                        "/home/ubuntu/tomcat/bin/startup.sh"
                        *BUT IT DO NOT START.*

                        4) Wrote a shell script and kept at the
                        same location from where I am
                        downloading tomcat.tar, downloaded the
                        run_tomcat.sh on to the chef-client
                        (using resource remote_file). Set
                        environment variables using
                        "environment resource" and run script
                        using "execute" resource.
                        Inside this run_tomcat.sh, running the
                        "/home/ubuntu/tomcat/bin/startup.sh"
                        *BUT IT DO NOT START.

                        *
                        For point 3 and 4 above the strange
                        thing is that other commands inside
                        run_tomcat.sh, like extracting war,
                        deleting some directory from the
                        extracted war executes. *BUT TOMCAT
                        DOESN'T START UP.*

                        I tried couple of other things also,
                        but is not able to start or stop the
                        tomcat.

                        On Fri, May 10, 2013 at 11:00 PM,
                        Chandan Maheshwari
                        <cmaheshwari16@gmail.com> wrote:


                            Hi All,

                            This may be a stupid or a silly
                            question. But I am finding issues
                            in getting it done.

                            Basically I have wrote a cookbook,
                            where I am simply downloading a tar
                            file of tomcat with other stuff
                            related to my app from some location.

                            Then I am using some resources to
                            untar it to define a specific
                            folder structure onto my new
                            instance created using knife ec2
                            plugin. (to be specific ubuntu)

                            Now I have one shell script which
                            basically stops the tomcat,
                            extracts my application war in
                            particular location, removes some
                            unwanted files from the extracted
                            war and then starts the tomcat back.

                            I am executing this script using
                            "execute" and in command passing
                            the full path of the script. The
                            script does everything (extracts my
                            application war in particular
                            location, removes some unwanted
                            files from the extracted war), but
                            it do not stops the tomcat and then
                            starts it back.

                            The chef-client runs successfully.

                            Now when I login to the newly
                            created instance, I can't see any
                            tomcat logs. Moreover when I run
                            the shell script manually (which I
                            ran with cookbook also), it does
                            everything and I can hit the URL to
                            access my app.

                            Any help is greatly appreciated.

                            I don't want to use the existing
                            tomcat cookbook, as I want to try
                            it from my location(where I have
                            kept the tomcat.tar) also I want to
                            use tomcat7.

                            -- 
                            Thanks and Regards,
                            Chandan




                        -- 
                        Regards,
                        Chandan



                    -- 
                    --
                    ~*~ StormeRider ~*~

                    "Every world needs its heroes [...] They
                    inspire us to be better than we are. And
                    they protect from the darkness that's just
                    around the corner."

                    (from Smallville Season 6x1: "Zod")

                    On why I hate the phrase "that's so
                    lame"... http://bit.ly/Ps3uSS




                -- 
                Regards,
                Chandan
        -- 
        Regards,
        Chandan
-- 
Regards,
Chandan

--
Regards,
Chandan

Remember, if sudo gets dropped into the mix:

"Defaults env_reset"

is part of the standard entry in visudo. You can specify to keep
certain environment variables if you need to by adding this to an
appropriate place:

"Defaults env_keep += JAVA_HOME"

Paul

On 5/12/2013 5:51 AM, Sascha Bates wrote:

Let's deal with getting your stuff working first, then we can worry
about making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running
the script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some
clarification, So Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are
much better off putting the JAVA_HOME, etc into your custom script.

           I have exported JAVA_HOME, etc in the script I am 

running. (where I am extracting war and then starting the tomcat). Is
this what you asked me to do.

If you are going to make your script the authority, don't depend on
Chef to do half the work, but ensure your script sources the files
you need or contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3) deploy
the file 4) start the tomcat app

               That is exactly what I need and am doing the same, 

through my default recipe I am running a script.sh(which I have
downloaded from remote location) Inside this script basically I am
extracting the war and then starting the tomcat, I have also exported
the variables in this script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def
that will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

            Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                   As I dont have that much experience so may be 

I don't find where and how the service will start from this. [Just to
make a note here I an not downloading/installing tomcat using the
community "tomcat cookbook". In my recipe I am downloading the tar of
tomcat and extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates <sascha.bates@gmail.com
mailto:sascha.bates@gmail.com> wrote:

The execute block will start your process as that user, but I'm
not positive that it will source the user environment files.  You
are much better off putting the JAVA_HOME, etc into your custom
script.

I'd put it like this:

If you are going to make your script the authority, don't depend
on Chef to do half the work, but ensure your script sources the
files you need or contains the environment variables it requires
OR
You might consider reconstructing your script into a chef
recipe/def that will 1) download a remote file, 2) stop the
tomcat app 3) deploy the file 4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger
service start stops from Chef.

Many of us in the community have wrestled with Java apps and
would be happy to help you refactor your recipe into something
that takes better advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:
---------------------------
Here is an example of the pattern I'm talking about:
https://gist.github.com/sbates/5563535
This is a link to a definition I threw together for deploying
Tomcat apps in a dev env from Artifactory. Note that this is not
a production-ready pattern. It just runs, notices if there's a
new war to deploy and then stops the service, deletes the old
war, and notifies the "deploy" to run which basically copies in
the new war and restarts the service.

The important part of this to look at is notifications to stop,
delete and deploy.  That pattern is really what you're looking to
manage with Chef or your deploy script.

You can also manage your war file manipulations with tools like
Bryan Berry's Ark resource
(http://community.opscode.com/cookbooks/ark) or the Riot Games
Artifact cookbook
(https://github.com/RiotGames/artifact-cookbook) if you have
complex needs.   I can also elaborate on why I wrote some
separate code instead of re-using community code in a separate
email if anyone wants.

Bryan has also written a library for managing JVM Args:
https://github.com/bryanwb/jvmargs

I hope some of this helps and doesn't further confuse.

Sascha


Morgan Blackthorne wrote:
I would log in as the user and check to make sure that those
values are set. Also, if it's in .bashrc and startup.sh is using
/bin/sh, then they likely won't get loaded-- you might need to
move it to something like .profile (I forget exactly what
startup file(s) sh loads but I believe .bashrc / .bash_profile
isn't included).

-- 
~*~ StormeRider ~*~

"Every world needs its heroes [...] They inspire us to be better
than we are. And they protect from the darkness that's just
around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS


On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari
<cmaheshwari16@gmail.com <mailto:cmaheshwari16@gmail.com>> wrote:

    Thanks Morgan,

    I am afraid, but it doesn't give any error. The chef-client
    runs successfully and creates node and client onto my
    chef-server. Any other location where I can check logs after
    logging into the newly created instance.

    Also there are no logs for tomcat also.

    I did some troubleshooting initially to redirect output of
    command ..../tomcat/bin/startup.sh in a .txt file and saw
    that it says:
    "Neither JAVA_HOME nor JRE_HOME is set, need at least one to
    set" But now I am setting those in ~/.bashrc file also.

    Can you guide me what other trouble shooting I can do.


    On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne
    <stormerider@gmail.com <mailto:stormerider@gmail.com>> wrote:

        Specifying what error it runs I to will probably help
        folks help you. It's standard troubleshooting question
        number one: what happens when you try?


        On Sunday, May 12, 2013, Chandan Maheshwari wrote:

            To be more specific, here is what all I have tried:

            I have my cookbook: where in my recipe, I am
            downloading tomcat.tar (this I have placed somewhere
            in my other machine). After downloading I extract
            the same tomcat.tar (suppose in location
            /home/ubuntu/tomcat). Now I am simply trying to
            start tomcat. I tried the below mentioned ways, but
            is not able to start/stop.

            1) Modified the ~/.bashrc file from my recipe to
            export JAVA_HOME, CATALINA_HOME,
            What I did is:

            In a recipe inside bash script simply added the
            environment variables at the end of ~/.bashrc and
            then ran source ~/.bashrc [ this works I can verify
            from ~/.bashrc file)

            Now using "execute" resource, ran
            "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT DO NOT
            START.*

            2) Modified the ~/.bashrc file from my recipe to
            export JAVA_HOME, CATALINA_HOME,
            What I did is:

            ran a bash script inside recipe to simply add the
            environment variables at the end of ~/.bashrc and
            then ran source ~/.bashrc

            Inside bash script resource, ran
            "/home/ubuntu/tomcat/bin/startup.sh" *BUT IT DO NOT
            START.*

            3) Wrote a shell script and kept at the same
            location from where I am downloading tomcat.tar,
            downloaded the run_tomcat.sh on to the chef-client
            (using resource remote_file) and then using the
            "execute" resource running the run_tomcat.sh.
            Inside this run_tomcat.sh, I am exporting the
            environment variables and then running the
            "/home/ubuntu/tomcat/bin/startup.sh"
            *BUT IT DO NOT START.*

            4) Wrote a shell script and kept at the same
            location from where I am downloading tomcat.tar,
            downloaded the run_tomcat.sh on to the chef-client
            (using resource remote_file). Set environment
            variables using "environment resource" and run
            script using "execute" resource.
            Inside this run_tomcat.sh, running the
            "/home/ubuntu/tomcat/bin/startup.sh"
            *BUT IT DO NOT START.

            *
            For point 3 and 4 above the strange thing is that
            other commands inside run_tomcat.sh, like extracting
            war, deleting some directory from the extracted war
            executes. *BUT TOMCAT DOESN'T START UP.*

            I tried couple of other things also, but is not able
            to start or stop the tomcat.

            On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari
            <cmaheshwari16@gmail.com> wrote:


                Hi All,

                This may be a stupid or a silly question. But I
                am finding issues in getting it done.

                Basically I have wrote a cookbook, where I am
                simply downloading a tar file of tomcat with
                other stuff related to my app from some location.

                Then I am using some resources to untar it to
                define a specific folder structure onto my new
                instance created using knife ec2 plugin. (to be
                specific ubuntu)

                Now I have one shell script which basically
                stops the tomcat, extracts my application war in
                particular location, removes some unwanted files
                from the extracted war and then starts the
                tomcat back.

                I am executing this script using "execute" and
                in command passing the full path of the script.
                The script does everything (extracts my
                application war in particular location, removes
                some unwanted files from the extracted war), but
                it do not stops the tomcat and then starts it back.

                The chef-client runs successfully.

                Now when I login to the newly created instance,
                I can't see any tomcat logs. Moreover when I run
                the shell script manually (which I ran with
                cookbook also), it does everything and I can hit
                the URL to access my app.

                Any help is greatly appreciated.

                I don't want to use the existing tomcat
                cookbook, as I want to try it from my
                location(where I have kept the tomcat.tar) also
                I want to use tomcat7.

                -- 
                Thanks and Regards,
                Chandan




            -- 
            Regards,
            Chandan



        -- 
        -- 
        ~*~ StormeRider ~*~

        "Every world needs its heroes [...] They inspire us to
        be better than we are. And they protect from the
        darkness that's just around the corner."

        (from Smallville Season 6x1: "Zod")

        On why I hate the phrase "that's so lame"...
        http://bit.ly/Ps3uSS




    -- 
    Regards,
    Chandan

--
Regards,
Chandan

Sorry Paul but I didn't get it. Should I use the above line once I set the
environment JAVA_HOME

On Sun, May 12, 2013 at 11:33 PM, Paul Graydon paul@paulgraydon.co.ukwrote:

Remember, if sudo gets dropped into the mix:

"Defaults env_reset"

is part of the standard entry in visudo. You can specify to keep certain
environment variables if you need to by adding this to an appropriate place:

"Defaults env_keep += JAVA_HOME"

Paul

On 5/12/2013 5:51 AM, Sascha Bates wrote:

Let's deal with getting your stuff working first, then we can worry about
making it pretty with chef.

I am guessing this is your problem:

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt

You are exporting your JAVA home as the ubuntu user and then running the
script as root.

Look: As the vagrant user I export my JAVA_HOME and I can see it in my
environment variables, but if I then check with sudo, it's not there.
vagrant@saschabX-vagrant:~$ env|grep JAVA
vagrant@saschabX-vagrant:~$ export JAVA_HOME=/opt/java/myjava
vagrant@saschabX-vagrant:~$ env|grep JAVA
JAVA_HOME=/opt/java/myjava <<<<--------------
vagrant@saschabX-vagrant:~$ sudo env|grep JAVA
vagrant@saschabX-vagrant:~$

Chandan Maheshwari wrote:

Hi Sascha,

Thanks for the great elaboration, but I still needs some clarification,
So Sorry for this.

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

            I have exported JAVA_HOME, etc in the script I am running.

(where I am extracting war and then starting the tomcat). Is this what you
asked me to do.

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

                That is exactly what I need and am doing the same,

through my default recipe I am running a script.sh(which I have downloaded
from remote location) Inside this script basically I am extracting the war
and then starting the tomcat, I have also exported the variables in this
script. Here is the snippet:

execute "redeploy_apps" do
cwd "#{extract_path_scripts}"
user "ubuntu"
#environment 'JAVA_HOME' => "#{extract_path_java}/jdk1.6.0_45"
command "sh #{extract_path_scripts}/#{redeploy_apps_script}"
end

NOTE I tried with root user also.

In the redeploy_apps_script I have :

export JAVA_HOME=/home/ubuntu/jdk1.6.0_45
sudo /home/ubuntu/scripts/apps_stop.sh > /home/ubuntu/scripts/stop.txt
echo "Stopping APP Please Wait"
sleep 30
rm -rf /home/ubuntu/tomcat/logs/*
rm -rf /home/ubuntu/tomcat/work/*

rm -rf /home/ubuntu/tomcat/webapps/apps
mkdir /home/ubuntu/tomcat/webapps/apps

rm -rf /home/ubuntu/tomcat/webapps/static
mkdir /home/ubuntu/tomcat/webapps/static

cd /home/ubuntu/tomcat/webapps/apps
echo "Extracting War"
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

cd /home/ubuntu/tomcat/webapps/static
/home/ubuntu/jdk1.6.0_45/bin/jar -xf /home/ubuntu/war/apps.war

*sudo /home/ubuntu/scripts/apps_start.sh > /home/ubuntu/scripts/start.sh
*

Except the lines in bold everything works.

You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3)
deploy the file 4) start the tomcat app

             Would appreciate a lot if you can help me in this.

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub

                    As I dont have that much experience so may be I

don't find where and how the service will start from this. [Just to make a
note here I an not downloading/installing tomcat using the community
"tomcat cookbook". In my recipe I am downloading the tar of tomcat and
extracting it.

Sorry If the above queries are too basic, please bare it.

On Sun, May 12, 2013 at 7:15 PM, Sascha Bates sascha.bates@gmail.comwrote:

The execute block will start your process as that user, but I'm not
positive that it will source the user environment files. You are much
better off putting the JAVA_HOME, etc into your custom script.

I'd put it like this:

If you are going to make your script the authority, don't depend on Chef
to do half the work, but ensure your script sources the files you need or
contains the environment variables it requires
OR
You might consider reconstructing your script into a chef recipe/def that
will 1) download a remote file, 2) stop the tomcat app 3) deploy the file
4) start the tomcat app

In this fashion, you can set up tomcat as a service and trigger service
start stops from Chef.

Many of us in the community have wrestled with Java apps and would be
happy to help you refactor your recipe into something that takes better
advantage of Chef's primitives.

tl;dr discussion about tomcat deploy strategies:

Here is an example of the pattern I'm talking about:
deploy_tomcat_app.rb · GitHub
This is a link to a definition I threw together for deploying Tomcat apps
in a dev env from Artifactory. Note that this is not a production-ready
pattern. It just runs, notices if there's a new war to deploy and then
stops the service, deletes the old war, and notifies the "deploy" to run
which basically copies in the new war and restarts the service.

The important part of this to look at is notifications to stop, delete
and deploy. That pattern is really what you're looking to manage with Chef
or your deploy script.

You can also manage your war file manipulations with tools like Bryan
Berry's Ark resource (http://community.opscode.com/cookbooks/ark) or the
Riot Games Artifact cookbook (
GitHub - RiotGamesCookbooks/artifact-cookbook: Provides your cookbooks with the Artifact Deploy LWRP) if you have complex
needs. I can also elaborate on why I wrote some separate code instead of
re-using community code in a separate email if anyone wants.

Bryan has also written a library for managing JVM Args:
GitHub - bryanwb/jvmargs: sane parser of java command-line arguments

I hope some of this helps and doesn't further confuse.

Sascha

Morgan Blackthorne wrote:

I would log in as the user and check to make sure that those values are
set. Also, if it's in .bashrc and startup.sh is using /bin/sh, then they
likely won't get loaded-- you might need to move it to something like
.profile (I forget exactly what startup file(s) sh loads but I believe
.bashrc / .bash_profile isn't included).

--
~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

On Sun, May 12, 2013 at 4:43 AM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Thanks Morgan,

I am afraid, but it doesn't give any error. The chef-client runs
successfully and creates node and client onto my chef-server. Any other
location where I can check logs after logging into the newly created
instance.

Also there are no logs for tomcat also.

I did some troubleshooting initially to redirect output of command
..../tomcat/bin/startup.sh in a .txt file and saw that it says:
"Neither JAVA_HOME nor JRE_HOME is set, need at least one to set" But
now I am setting those in ~/.bashrc file also.

Can you guide me what other trouble shooting I can do.

On Sun, May 12, 2013 at 5:00 PM, Morgan Blackthorne <
stormerider@gmail.com> wrote:

Specifying what error it runs I to will probably help folks help you.
It's standard troubleshooting question number one: what happens when you
try?

On Sunday, May 12, 2013, Chandan Maheshwari wrote:

To be more specific, here is what all I have tried:

I have my cookbook: where in my recipe, I am downloading
tomcat.tar (this I have placed somewhere in my other machine). After
downloading I extract the same tomcat.tar (suppose in location
/home/ubuntu/tomcat). Now I am simply trying to start tomcat. I tried the
below mentioned ways, but is not able to start/stop.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

In a recipe inside bash script simply added the environment variables
at the end of ~/.bashrc and then ran source ~/.bashrc [ this works I can
verify from ~/.bashrc file)

Now using "execute" resource, ran
"/home/ubuntu/tomcat/bin/startup.sh" BUT IT DO NOT START.

  1. Modified the ~/.bashrc file from my recipe to export JAVA_HOME,
    CATALINA_HOME,
    What I did is:

ran a bash script inside recipe to simply add the environment
variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

  1. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file) and then using the "execute" resource running
    the run_tomcat.sh.
    Inside this run_tomcat.sh, I am exporting the environment variables
    and then running the "/home/ubuntu/tomcat/bin/startup.sh"
    BUT IT DO NOT START.

  2. Wrote a shell script and kept at the same location from where I am
    downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client
    (using resource remote_file). Set environment variables using "environment
    resource" and run script using "execute" resource.
    Inside this run_tomcat.sh, running the
    "/home/ubuntu/tomcat/bin/startup.sh"
    *BUT IT DO NOT START.

For point 3 and 4 above the strange thing is that other commands
inside run_tomcat.sh, like extracting war, deleting some directory from the
extracted war executes. BUT TOMCAT DOESN'T START UP.

I tried couple of other things also, but is not able to start or
stop the tomcat.

On Fri, May 10, 2013 at 11:00 PM, Chandan Maheshwari <
cmaheshwari16@gmail.com> wrote:

Hi All,

This may be a stupid or a silly question. But I am finding issues in
getting it done.

Basically I have wrote a cookbook, where I am simply downloading a
tar file of tomcat with other stuff related to my app from some location.

Then I am using some resources to untar it to define a specific
folder structure onto my new instance created using knife ec2 plugin. (to
be specific ubuntu)

Now I have one shell script which basically stops the tomcat,
extracts my application war in particular location, removes some unwanted
files from the extracted war and then starts the tomcat back.

I am executing this script using "execute" and in command passing
the full path of the script. The script does everything (extracts my
application war in particular location, removes some unwanted files from
the extracted war), but it do not stops the tomcat and then starts it back.

The chef-client runs successfully.

Now when I login to the newly created instance, I can't see any
tomcat logs. Moreover when I run the shell script manually (which I ran
with cookbook also), it does everything and I can hit the URL to access my
app.

Any help is greatly appreciated.

I don't want to use the existing tomcat cookbook, as I want to try
it from my location(where I have kept the tomcat.tar) also I want to use
tomcat7.

--
Thanks and Regards,
Chandan

--
Regards,
Chandan

--

~~ StormeRider ~~

"Every world needs its heroes [...] They inspire us to be better than
we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS

--
Regards,
Chandan

--
Regards,
Chandan

--
Regards,
Chandan