You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Nishant Chandra <ni...@gmail.com> on 2013/09/13 19:55:37 UTC

Need help running scripts on EC2

Hi,

I am trying to run a script like this on multiple EC2 servers:

for (NodeMetadata node : nodes) {
String runScript = new ScriptBuilder()
.addStatement(exec("sh run.sh"))
.render(org.jclouds.scriptbuilder.domain.OsFamily.UNIX);

ListenableFuture<ExecResponse> responses =
context.getComputeService().submitScriptOnNode(node.getId(),
runScript,
wrapInInitScript(false).runAsRoot(false).nameTask("Test"));

}

The script does not start. The script starts a server and exits, something
like java -jar somejar.jar

How can it get to work?

Thanks,
Nishant

Re: Need help running scripts on EC2

Posted by Ignasi <ig...@gmail.com>.
I've had a look and I think we can get rid of the shopt command with
little changes. I've filed an issue to keep track of this:
https://issues.apache.org/jira/browse/JCLOUDS-283

On 13 September 2013 23:09, Ignasi <ig...@gmail.com> wrote:
> Nishant, could you share the ami id of that image and the details of the
> failure?
>
> I extensively test jclouds-chef with Ubuntu AMIs (with the wrapper script)
> and it works.
>
> El 13/09/2013 23:01, "Nishant Chandra" <ni...@gmail.com> escribió:
>
>> It fails on Ubuntu. I tried that before moving to Amazon AMI.
>>
>>
>> On Sat, Sep 14, 2013 at 2:14 AM, Ignasi <ig...@gmail.com> wrote:
>>>
>>> Glad to hear it works!
>>>
>>> Yes. You'll see a symlink in your home pointing to the script that is
>>> actually executed. You can read it to have a better understanding of how it
>>> works.
>>>
>>> Zack: do you know an AMI that doesn't support that? I'll have a look and
>>> try to build a working wrapper.
>>>
>>> El 13/09/2013 22:21, "Nishant Chandra" <ni...@gmail.com>
>>> escribió:
>>>>
>>>> I am using Amazon linux 64 bit AMI.
>>>>
>>>> Thanks Ignasi. I could debug and realized that if I wrap it in init
>>>> script and gave full path to the script i.e.
>>>> .addStatement(exec("/home/ec2-user/run.sh")), then it worked.
>>>>
>>>> So is it that temporary scripts are created in /tmp and user scripts are
>>>> executed from there?
>>>>
>>>>
>>>>
>>>> On Sat, Sep 14, 2013 at 12:57 AM, Zack Shoylev
>>>> <za...@rackspace.com> wrote:
>>>>>
>>>>> I have seen some images that do not support bash-shopt which is what
>>>>> jclouds uses to wrap scripts (in the header).
>>>>> What image is being used?
>>>>>
>>>>> ________________________________
>>>>> From: Ignasi [ignasi.barrera@gmail.com]
>>>>> Sent: Friday, September 13, 2013 2:19 PM
>>>>> To: user@jclouds.incubator.apache.org
>>>>> Subject: Need help running scripts on EC2
>>>>>
>>>>> A couple considerations:
>>>>>
>>>>> * You don't have to manually render the script. You can directle pass
>>>>> the 'exec("foo")' to the submitScriptOnNode method and jclouds will take
>>>>> care of rendering it properly depending on the type of the Template being
>>>>> deployed.
>>>>> * Why don't you want to wrap it in the init script? If you wrap it
>>>>> (which is done by default), you will see a directory created in /tmp
>>>>> containing files with the stdout and the stderr for the script. You can tail
>>>>> them to see the progress, or paste them here to diagnose what can be going
>>>>> on.
>>>>> * By default jclouds waits until the script completes, so if the server
>>>>> is started in the foreground by your script, it may not terminate, and the
>>>>> returned future will wait forever. If this is the case, perhaps a better
>>>>> approach would be to wrap your script in a nohup.
>>>>>
>>>>>
>>>>> HTH
>>>>>
>>>>> Ignasi
>>>>>
>>>>>
>>>>> On Friday, 13 September 2013, Andrew Phillips wrote:
>>>>>>>
>>>>>>> The script does not start. The script starts a server and exits,
>>>>>>> something
>>>>>>> like java -jar somejar.jar
>>>>>>
>>>>>>
>>>>>> Have you tried putting any "echo starting > /my/log/file" statements
>>>>>> in the script, just to see if it even ever gets invoked?
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> ap
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Nishant Chandra
>>>> Bangalore, India
>>>> Cell : +91 9739131616
>>
>>
>>
>>
>> --
>> Nishant Chandra
>> Bangalore, India
>> Cell : +91 9739131616

Re: Need help running scripts on EC2

Posted by Ignasi <ig...@gmail.com>.
Nishant, could you share the ami id of that image and the details of the
failure?

I extensively test jclouds-chef with Ubuntu AMIs (with the wrapper script)
and it works.
El 13/09/2013 23:01, "Nishant Chandra" <ni...@gmail.com> escribió:

> It fails on Ubuntu. I tried that before moving to Amazon AMI.
>
>
> On Sat, Sep 14, 2013 at 2:14 AM, Ignasi <ig...@gmail.com> wrote:
>
>> Glad to hear it works!
>>
>> Yes. You'll see a symlink in your home pointing to the script that is
>> actually executed. You can read it to have a better understanding of how it
>> works.
>>
>> Zack: do you know an AMI that doesn't support that? I'll have a look and
>> try to build a working wrapper.
>> El 13/09/2013 22:21, "Nishant Chandra" <ni...@gmail.com>
>> escribió:
>>
>>> I am using Amazon linux 64 bit AMI.
>>>
>>> Thanks Ignasi. I could debug and realized that if I wrap it in init
>>> script and gave full path to the script i.e.
>>> .addStatement(exec("/home/ec2-user/run.sh")), then it worked.
>>>
>>> So is it that temporary scripts are created in /tmp and user scripts are
>>> executed from there?
>>>
>>>
>>>
>>> On Sat, Sep 14, 2013 at 12:57 AM, Zack Shoylev <
>>> zack.shoylev@rackspace.com> wrote:
>>>
>>>>  I have seen some images that do not support bash-shopt which is what
>>>> jclouds uses to wrap scripts (in the header).
>>>> What image is being used?
>>>>
>>>>  ------------------------------
>>>> *From:* Ignasi [ignasi.barrera@gmail.com]
>>>> *Sent:* Friday, September 13, 2013 2:19 PM
>>>> *To:* user@jclouds.incubator.apache.org
>>>> *Subject:* Need help running scripts on EC2
>>>>
>>>>  A couple considerations:
>>>>
>>>>  * You don't have to manually render the script. You can directle pass
>>>> the 'exec("foo")' to the submitScriptOnNode method and jclouds will take
>>>> care of rendering it properly depending on the type of the Template being
>>>> deployed.
>>>> * Why don't you want to wrap it in the init script? If you wrap it
>>>> (which is done by default), you will see a directory created in /tmp
>>>> containing files with the stdout and the stderr for the script. You can
>>>> tail them to see the progress, or paste them here to diagnose what can be
>>>> going on.
>>>> * By default jclouds waits until the script completes, so if the server
>>>> is started in the foreground by your script, it may not terminate, and the
>>>> returned future will wait forever. If this is the case, perhaps a better
>>>> approach would be to wrap your script in a nohup.
>>>>
>>>>
>>>>  HTH
>>>>
>>>>  Ignasi
>>>>
>>>>
>>>> On Friday, 13 September 2013, Andrew Phillips wrote:
>>>>
>>>>>  The script does not start. The script starts a server and exits,
>>>>>> something
>>>>>> like java -jar somejar.jar
>>>>>>
>>>>>
>>>>> Have you tried putting any "echo starting > /my/log/file" statements
>>>>> in the script, just to see if it even ever gets invoked?
>>>>>
>>>>> Regards
>>>>>
>>>>> ap
>>>>>
>>>>
>>>
>>>
>>> --
>>> Nishant Chandra
>>> Bangalore, India
>>> Cell : +91 9739131616
>>>
>>
>
>
> --
> Nishant Chandra
> Bangalore, India
> Cell : +91 9739131616
>

Re: Need help running scripts on EC2

Posted by Nishant Chandra <ni...@gmail.com>.
It fails on Ubuntu. I tried that before moving to Amazon AMI.


On Sat, Sep 14, 2013 at 2:14 AM, Ignasi <ig...@gmail.com> wrote:

> Glad to hear it works!
>
> Yes. You'll see a symlink in your home pointing to the script that is
> actually executed. You can read it to have a better understanding of how it
> works.
>
> Zack: do you know an AMI that doesn't support that? I'll have a look and
> try to build a working wrapper.
> El 13/09/2013 22:21, "Nishant Chandra" <ni...@gmail.com>
> escribió:
>
>> I am using Amazon linux 64 bit AMI.
>>
>> Thanks Ignasi. I could debug and realized that if I wrap it in init
>> script and gave full path to the script i.e.
>> .addStatement(exec("/home/ec2-user/run.sh")), then it worked.
>>
>> So is it that temporary scripts are created in /tmp and user scripts are
>> executed from there?
>>
>>
>>
>> On Sat, Sep 14, 2013 at 12:57 AM, Zack Shoylev <
>> zack.shoylev@rackspace.com> wrote:
>>
>>>  I have seen some images that do not support bash-shopt which is what
>>> jclouds uses to wrap scripts (in the header).
>>> What image is being used?
>>>
>>>  ------------------------------
>>> *From:* Ignasi [ignasi.barrera@gmail.com]
>>> *Sent:* Friday, September 13, 2013 2:19 PM
>>> *To:* user@jclouds.incubator.apache.org
>>> *Subject:* Need help running scripts on EC2
>>>
>>>  A couple considerations:
>>>
>>>  * You don't have to manually render the script. You can directle pass
>>> the 'exec("foo")' to the submitScriptOnNode method and jclouds will take
>>> care of rendering it properly depending on the type of the Template being
>>> deployed.
>>> * Why don't you want to wrap it in the init script? If you wrap it
>>> (which is done by default), you will see a directory created in /tmp
>>> containing files with the stdout and the stderr for the script. You can
>>> tail them to see the progress, or paste them here to diagnose what can be
>>> going on.
>>> * By default jclouds waits until the script completes, so if the server
>>> is started in the foreground by your script, it may not terminate, and the
>>> returned future will wait forever. If this is the case, perhaps a better
>>> approach would be to wrap your script in a nohup.
>>>
>>>
>>>  HTH
>>>
>>>  Ignasi
>>>
>>>
>>> On Friday, 13 September 2013, Andrew Phillips wrote:
>>>
>>>>  The script does not start. The script starts a server and exits,
>>>>> something
>>>>> like java -jar somejar.jar
>>>>>
>>>>
>>>> Have you tried putting any "echo starting > /my/log/file" statements in
>>>> the script, just to see if it even ever gets invoked?
>>>>
>>>> Regards
>>>>
>>>> ap
>>>>
>>>
>>
>>
>> --
>> Nishant Chandra
>> Bangalore, India
>> Cell : +91 9739131616
>>
>


-- 
Nishant Chandra
Bangalore, India
Cell : +91 9739131616

RE: Need help running scripts on EC2

Posted by Zack Shoylev <za...@RACKSPACE.COM>.
Ignasi: I have seen that on "cirros-0.3.1-x86_64-uec" - this is one of the default devstack images.
________________________________
From: Ignasi [ignasi.barrera@gmail.com]
Sent: Friday, September 13, 2013 3:44 PM
To: user@jclouds.incubator.apache.org
Subject: Re: Need help running scripts on EC2


Glad to hear it works!

Yes. You'll see a symlink in your home pointing to the script that is actually executed. You can read it to have a better understanding of how it works.

Zack: do you know an AMI that doesn't support that? I'll have a look and try to build a working wrapper.

El 13/09/2013 22:21, "Nishant Chandra" <ni...@gmail.com>> escribió:
I am using Amazon linux 64 bit AMI.

Thanks Ignasi. I could debug and realized that if I wrap it in init script and gave full path to the script i.e.
.addStatement(exec("/home/ec2-user/run.sh")), then it worked.

So is it that temporary scripts are created in /tmp and user scripts are executed from there?



On Sat, Sep 14, 2013 at 12:57 AM, Zack Shoylev <za...@rackspace.com>> wrote:
I have seen some images that do not support bash-shopt which is what jclouds uses to wrap scripts (in the header).
What image is being used?

________________________________
From: Ignasi [ignasi.barrera@gmail.com<ma...@gmail.com>]
Sent: Friday, September 13, 2013 2:19 PM
To: user@jclouds.incubator.apache.org<ma...@jclouds.incubator.apache.org>
Subject: Need help running scripts on EC2

A couple considerations:

* You don't have to manually render the script. You can directle pass the 'exec("foo")' to the submitScriptOnNode method and jclouds will take care of rendering it properly depending on the type of the Template being deployed.
* Why don't you want to wrap it in the init script? If you wrap it (which is done by default), you will see a directory created in /tmp containing files with the stdout and the stderr for the script. You can tail them to see the progress, or paste them here to diagnose what can be going on.
* By default jclouds waits until the script completes, so if the server is started in the foreground by your script, it may not terminate, and the returned future will wait forever. If this is the case, perhaps a better approach would be to wrap your script in a nohup.


HTH

Ignasi


On Friday, 13 September 2013, Andrew Phillips wrote:
The script does not start. The script starts a server and exits, something
like java -jar somejar.jar

Have you tried putting any "echo starting > /my/log/file" statements in the script, just to see if it even ever gets invoked?

Regards

ap



--
Nishant Chandra
Bangalore, India
Cell : +91 9739131616<tel:%2B91%209739131616>

Re: Need help running scripts on EC2

Posted by Ignasi <ig...@gmail.com>.
Glad to hear it works!

Yes. You'll see a symlink in your home pointing to the script that is
actually executed. You can read it to have a better understanding of how it
works.

Zack: do you know an AMI that doesn't support that? I'll have a look and
try to build a working wrapper.
El 13/09/2013 22:21, "Nishant Chandra" <ni...@gmail.com> escribió:

> I am using Amazon linux 64 bit AMI.
>
> Thanks Ignasi. I could debug and realized that if I wrap it in init script
> and gave full path to the script i.e.
> .addStatement(exec("/home/ec2-user/run.sh")), then it worked.
>
> So is it that temporary scripts are created in /tmp and user scripts are
> executed from there?
>
>
>
> On Sat, Sep 14, 2013 at 12:57 AM, Zack Shoylev <zack.shoylev@rackspace.com
> > wrote:
>
>>  I have seen some images that do not support bash-shopt which is what
>> jclouds uses to wrap scripts (in the header).
>> What image is being used?
>>
>>  ------------------------------
>> *From:* Ignasi [ignasi.barrera@gmail.com]
>> *Sent:* Friday, September 13, 2013 2:19 PM
>> *To:* user@jclouds.incubator.apache.org
>> *Subject:* Need help running scripts on EC2
>>
>>  A couple considerations:
>>
>>  * You don't have to manually render the script. You can directle pass
>> the 'exec("foo")' to the submitScriptOnNode method and jclouds will take
>> care of rendering it properly depending on the type of the Template being
>> deployed.
>> * Why don't you want to wrap it in the init script? If you wrap it (which
>> is done by default), you will see a directory created in /tmp containing
>> files with the stdout and the stderr for the script. You can tail them to
>> see the progress, or paste them here to diagnose what can be going on.
>> * By default jclouds waits until the script completes, so if the server
>> is started in the foreground by your script, it may not terminate, and the
>> returned future will wait forever. If this is the case, perhaps a better
>> approach would be to wrap your script in a nohup.
>>
>>
>>  HTH
>>
>>  Ignasi
>>
>>
>> On Friday, 13 September 2013, Andrew Phillips wrote:
>>
>>>  The script does not start. The script starts a server and exits,
>>>> something
>>>> like java -jar somejar.jar
>>>>
>>>
>>> Have you tried putting any "echo starting > /my/log/file" statements in
>>> the script, just to see if it even ever gets invoked?
>>>
>>> Regards
>>>
>>> ap
>>>
>>
>
>
> --
> Nishant Chandra
> Bangalore, India
> Cell : +91 9739131616
>

Re: Need help running scripts on EC2

Posted by Nishant Chandra <ni...@gmail.com>.
I am using Amazon linux 64 bit AMI.

Thanks Ignasi. I could debug and realized that if I wrap it in init script
and gave full path to the script i.e.
.addStatement(exec("/home/ec2-user/run.sh")), then it worked.

So is it that temporary scripts are created in /tmp and user scripts are
executed from there?



On Sat, Sep 14, 2013 at 12:57 AM, Zack Shoylev
<za...@rackspace.com>wrote:

>  I have seen some images that do not support bash-shopt which is what
> jclouds uses to wrap scripts (in the header).
> What image is being used?
>
>  ------------------------------
> *From:* Ignasi [ignasi.barrera@gmail.com]
> *Sent:* Friday, September 13, 2013 2:19 PM
> *To:* user@jclouds.incubator.apache.org
> *Subject:* Need help running scripts on EC2
>
>  A couple considerations:
>
>  * You don't have to manually render the script. You can directle pass
> the 'exec("foo")' to the submitScriptOnNode method and jclouds will take
> care of rendering it properly depending on the type of the Template being
> deployed.
> * Why don't you want to wrap it in the init script? If you wrap it (which
> is done by default), you will see a directory created in /tmp containing
> files with the stdout and the stderr for the script. You can tail them to
> see the progress, or paste them here to diagnose what can be going on.
> * By default jclouds waits until the script completes, so if the server is
> started in the foreground by your script, it may not terminate, and the
> returned future will wait forever. If this is the case, perhaps a better
> approach would be to wrap your script in a nohup.
>
>
>  HTH
>
>  Ignasi
>
>
> On Friday, 13 September 2013, Andrew Phillips wrote:
>
>>  The script does not start. The script starts a server and exits,
>>> something
>>> like java -jar somejar.jar
>>>
>>
>> Have you tried putting any "echo starting > /my/log/file" statements in
>> the script, just to see if it even ever gets invoked?
>>
>> Regards
>>
>> ap
>>
>


-- 
Nishant Chandra
Bangalore, India
Cell : +91 9739131616

RE: Need help running scripts on EC2

Posted by Zack Shoylev <za...@RACKSPACE.COM>.
I have seen some images that do not support bash-shopt which is what jclouds uses to wrap scripts (in the header).
What image is being used?

________________________________
From: Ignasi [ignasi.barrera@gmail.com]
Sent: Friday, September 13, 2013 2:19 PM
To: user@jclouds.incubator.apache.org
Subject: Need help running scripts on EC2

A couple considerations:

* You don't have to manually render the script. You can directle pass the 'exec("foo")' to the submitScriptOnNode method and jclouds will take care of rendering it properly depending on the type of the Template being deployed.
* Why don't you want to wrap it in the init script? If you wrap it (which is done by default), you will see a directory created in /tmp containing files with the stdout and the stderr for the script. You can tail them to see the progress, or paste them here to diagnose what can be going on.
* By default jclouds waits until the script completes, so if the server is started in the foreground by your script, it may not terminate, and the returned future will wait forever. If this is the case, perhaps a better approach would be to wrap your script in a nohup.


HTH

Ignasi


On Friday, 13 September 2013, Andrew Phillips wrote:
The script does not start. The script starts a server and exits, something
like java -jar somejar.jar

Have you tried putting any "echo starting > /my/log/file" statements in the script, just to see if it even ever gets invoked?

Regards

ap

Need help running scripts on EC2

Posted by Ignasi <ig...@gmail.com>.
A couple considerations:

* You don't have to manually render the script. You can directle pass the
'exec("foo")' to the submitScriptOnNode method and jclouds will take care
of rendering it properly depending on the type of the Template being
deployed.
* Why don't you want to wrap it in the init script? If you wrap it (which
is done by default), you will see a directory created in /tmp containing
files with the stdout and the stderr for the script. You can tail them to
see the progress, or paste them here to diagnose what can be going on.
* By default jclouds waits until the script completes, so if the server is
started in the foreground by your script, it may not terminate, and the
returned future will wait forever. If this is the case, perhaps a better
approach would be to wrap your script in a nohup.


HTH

Ignasi


On Friday, 13 September 2013, Andrew Phillips wrote:

>  The script does not start. The script starts a server and exits, something
>> like java -jar somejar.jar
>>
>
> Have you tried putting any "echo starting > /my/log/file" statements in
> the script, just to see if it even ever gets invoked?
>
> Regards
>
> ap
>

Re: Need help running scripts on EC2

Posted by Andrew Phillips <an...@apache.org>.
> The script does not start. The script starts a server and exits, something
> like java -jar somejar.jar

Have you tried putting any "echo starting > /my/log/file" statements  
in the script, just to see if it even ever gets invoked?

Regards

ap