Omnibus 4.0 and Ohai question


#1

I am coming back to Omnibus and updating some software definitions
having not used Omnibus in 6 months.

I used to be able to reference Ohai[‘platform’] but that returns a no
method error on Omnibus 4.0

Error:

config/software/package.rb:20:in `evaluate': undefined method `[]'

for Ohai:Module (NoMethodError)

Line causing error:

version_name_string =

“#{Ohai[‘platform’]}-#{Ohai[‘platform_version’]}-#{Ohai[‘kernel’][‘machine’]}-#{version_string}”

So what do I need to do to reference Ohai data in an Omnibus 4.0
software definition?

I do know in some cases there are chef-sugar helpers like windows?
that can be used to switch on platform conditions. I couldn’t find
relevant documentation, and if someone could point me at an example it
would be kindly appreciated.


Eric G. Wolfe
email: eric.wolfe@cyclecomputing.com
cell: 304.942.3970
twitter: @atomic_penguin

Cycle Computing
Better Answers. Faster.


twitter: @cyclecomputing


#2

Hello,

While I try to figure out how to get node to at least temporarily log it’s errors,
I am hoping that there is a common issue with launching node instances
from Chef.

The recipe is simple:

The script has eight lines, all just like this:

run.sh:

node script1.js &
node script2.js &
node script3.js &
node script4.js &
node script5.js &
node script6.js &
node script7.js &

The entire recipe is:

execute “execute run.sh” do
cwd "/opt/prodname/data"
command "./run.sh"
action :run
end

At first I thought that it might not be running, but checking the process table
for instances of node (or processes that contain the string “node” ;0) showed that
the node instances were launched but that they dropped out of memory a few seconds
late: (every – == one second)

while (true) do ps -ef | grep node| grep -v grep; echo “–”; sleep 1; done


– (at first, they all appeared)
root 10983 1 5 20:49 ? 00:00:00 node script1.js
root 10984 1 6 20:49 ? 00:00:00 node script2.js
root 10985 1 6 20:49 ? 00:00:00 node script3.js
root 10986 1 7 20:49 ? 00:00:00 node script4.js
root 10987 1 5 20:49 ? 00:00:00 node script5.js
root 10988 1 7 20:49 ? 00:00:00 node script6.js
root 10989 1 6 20:49 ? 00:00:00 node script7.js

root 10983 1 16 20:49 ? 00:00:00 node script1.js
root 10984 1 16 20:49 ? 00:00:00 node script2.js
root 10985 1 18 20:49 ? 00:00:00 node script3.js
root 10986 1 18 20:49 ? 00:00:00 node script4.js
root 10987 1 16 20:49 ? 00:00:00 node script5.js
root 10988 1 17 20:49 ? 00:00:00 node script6.js
root 10989 1 16 20:49 ? 00:00:00 node script7.js

root 10985 1 20 20:49 ? 00:00:00 node script3.js <—then only 5!
root 10986 1 20 20:49 ? 00:00:00 node script4.js
root 10987 1 21 20:49 ? 00:00:00 node script5.js
root 10988 1 20 20:49 ? 00:00:00 node script6.js
root 10989 1 20 20:49 ? 00:00:00 node script7.js

– <— at this point they have all terminated

I tried adding redirection to the lines in run.sh, to ensure that no output was uncultured
but to no avail. (i.e. adding 2>&1 >/tmp/script#out resulted in no output to these logs)

This seems like more of a node question, and if you can confirm that this is the case,
then I will turn to that, with appreciation.

Thank you for the time!

Christopher


#3

Hello,

All apologies…I used an old message to get the address right, and left the old Subject there.

Take care,

Christopher

On Apr 18, 2015, at 4:08 PM, Christopher Hahn chahn@cognitivemedicine.com wrote:

Hello,

While I try to figure out how to get node to at least temporarily log it’s errors,
I am hoping that there is a common issue with launching node instances
from Chef.

The recipe is simple:

The script has eight lines, all just like this:

run.sh:

node script1.js &
node script2.js &
node script3.js &
node script4.js &
node script5.js &
node script6.js &
node script7.js &

The entire recipe is:

execute “execute run.sh” do
cwd "/opt/prodname/data"
command "./run.sh"
action :run
end

At first I thought that it might not be running, but checking the process table
for instances of node (or processes that contain the string “node” ;0) showed that
the node instances were launched but that they dropped out of memory a few seconds
late: (every – == one second)

while (true) do ps -ef | grep node| grep -v grep; echo “–”; sleep 1; done


– (at first, they all appeared)
root 10983 1 5 20:49 ? 00:00:00 node script1.js
root 10984 1 6 20:49 ? 00:00:00 node script2.js
root 10985 1 6 20:49 ? 00:00:00 node script3.js
root 10986 1 7 20:49 ? 00:00:00 node script4.js
root 10987 1 5 20:49 ? 00:00:00 node script5.js
root 10988 1 7 20:49 ? 00:00:00 node script6.js
root 10989 1 6 20:49 ? 00:00:00 node script7.js

root 10983 1 16 20:49 ? 00:00:00 node script1.js
root 10984 1 16 20:49 ? 00:00:00 node script2.js
root 10985 1 18 20:49 ? 00:00:00 node script3.js
root 10986 1 18 20:49 ? 00:00:00 node script4.js
root 10987 1 16 20:49 ? 00:00:00 node script5.js
root 10988 1 17 20:49 ? 00:00:00 node script6.js
root 10989 1 16 20:49 ? 00:00:00 node script7.js

root 10985 1 20 20:49 ? 00:00:00 node script3.js <—then only 5!
root 10986 1 20 20:49 ? 00:00:00 node script4.js
root 10987 1 21 20:49 ? 00:00:00 node script5.js
root 10988 1 20 20:49 ? 00:00:00 node script6.js
root 10989 1 20 20:49 ? 00:00:00 node script7.js

– <— at this point they have all terminated

I tried adding redirection to the lines in run.sh, to ensure that no output was uncultured
but to no avail. (i.e. adding 2>&1 >/tmp/script#out resulted in no output to these logs)

This seems like more of a node question, and if you can confirm that this is the case,
then I will turn to that, with appreciation.

Thank you for the time!

Christopher


#4

It seems that I fixed my problem by adding “sh -c” to the command and by redirecting
all output to /dev/null

Take care,

Christopher

On Apr 18, 2015, at 4:14 PM, Christopher Hahn chahn@cognitivemedicine.com wrote:

Hello,

All apologies…I used an old message to get the address right, and left the old Subject there.

Take care,

Christopher

On Apr 18, 2015, at 4:08 PM, Christopher Hahn chahn@cognitivemedicine.com wrote:

Hello,

While I try to figure out how to get node to at least temporarily log it’s errors,
I am hoping that there is a common issue with launching node instances
from Chef.

The recipe is simple:

The script has eight lines, all just like this:

run.sh:

node script1.js &
node script2.js &
node script3.js &
node script4.js &
node script5.js &
node script6.js &
node script7.js &

The entire recipe is:

execute “execute run.sh” do
cwd "/opt/prodname/data"
command "./run.sh"
action :run
end

At first I thought that it might not be running, but checking the process table
for instances of node (or processes that contain the string “node” ;0) showed that
the node instances were launched but that they dropped out of memory a few seconds
late: (every – == one second)

while (true) do ps -ef | grep node| grep -v grep; echo “–”; sleep 1; done


– (at first, they all appeared)
root 10983 1 5 20:49 ? 00:00:00 node script1.js
root 10984 1 6 20:49 ? 00:00:00 node script2.js
root 10985 1 6 20:49 ? 00:00:00 node script3.js
root 10986 1 7 20:49 ? 00:00:00 node script4.js
root 10987 1 5 20:49 ? 00:00:00 node script5.js
root 10988 1 7 20:49 ? 00:00:00 node script6.js
root 10989 1 6 20:49 ? 00:00:00 node script7.js

root 10983 1 16 20:49 ? 00:00:00 node script1.js
root 10984 1 16 20:49 ? 00:00:00 node script2.js
root 10985 1 18 20:49 ? 00:00:00 node script3.js
root 10986 1 18 20:49 ? 00:00:00 node script4.js
root 10987 1 16 20:49 ? 00:00:00 node script5.js
root 10988 1 17 20:49 ? 00:00:00 node script6.js
root 10989 1 16 20:49 ? 00:00:00 node script7.js

root 10985 1 20 20:49 ? 00:00:00 node script3.js <—then only 5!
root 10986 1 20 20:49 ? 00:00:00 node script4.js
root 10987 1 21 20:49 ? 00:00:00 node script5.js
root 10988 1 20 20:49 ? 00:00:00 node script6.js
root 10989 1 20 20:49 ? 00:00:00 node script7.js

– <— at this point they have all terminated

I tried adding redirection to the lines in run.sh, to ensure that no output was uncultured
but to no avail. (i.e. adding 2>&1 >/tmp/script#out resulted in no output to these logs)

This seems like more of a node question, and if you can confirm that this is the case,
then I will turn to that, with appreciation.

Thank you for the time!

Christopher


#5

Eric,

You can use “ohai[‘platform’]” (with lowercase “o”) in your software
definition:


Yvonne

On Wed, Apr 8, 2015 at 12:24 PM, Eric G. Wolfe eric.wolfe@gmail.com wrote:

I am coming back to Omnibus and updating some software definitions
having not used Omnibus in 6 months.

I used to be able to reference Ohai[‘platform’] but that returns a no
method error on Omnibus 4.0

Error:

config/software/package.rb:20:in `evaluate': undefined method `[]'

for Ohai:Module (NoMethodError)

Line causing error:

version_name_string =

“#{Ohai[‘platform’]}-#{Ohai[‘platform_version’]}-#{Ohai[‘kernel’][‘machine’]}-#{version_string}”

So what do I need to do to reference Ohai data in an Omnibus 4.0
software definition?

I do know in some cases there are chef-sugar helpers like windows?
that can be used to switch on platform conditions. I couldn’t find
relevant documentation, and if someone could point me at an example it
would be kindly appreciated.


Eric G. Wolfe
email: eric.wolfe@cyclecomputing.com
cell: 304.942.3970
twitter: @atomic_penguin

Cycle Computing
Better Answers. Faster.

http://www.cyclecomputing.com
twitter: @cyclecomputing


#6

Thank you, Yvonne!

Eric G. Wolfe
email: eric.wolfe@cyclecomputing.com
cell: 304.942.3970
twitter: @atomic_penguin

Cycle Computing
Better Answers. Faster.


twitter: @cyclecomputing

On 04/08/2015 04:00 PM, Yvonne Lam wrote:

Eric,

You can use “ohai[‘platform’]” (with lowercase “o”) in your software
definition:

https://github.com/chef/omnibus/blob/master/lib/omnibus/project.rb#L681-692
https://github.com/chef/omnibus-software/blob/master/config/software/ruby.rb#L77

Yvonne

On Wed, Apr 8, 2015 at 12:24 PM, Eric G. Wolfe eric.wolfe@gmail.com wrote:

I am coming back to Omnibus and updating some software definitions
having not used Omnibus in 6 months.

I used to be able to reference Ohai[‘platform’] but that returns a no
method error on Omnibus 4.0

Error:

config/software/package.rb:20:in `evaluate': undefined method `[]'

for Ohai:Module (NoMethodError)

Line causing error:

version_name_string =

“#{Ohai[‘platform’]}-#{Ohai[‘platform_version’]}-#{Ohai[‘kernel’][‘machine’]}-#{version_string}”

So what do I need to do to reference Ohai data in an Omnibus 4.0
software definition?

I do know in some cases there are chef-sugar helpers like windows?
that can be used to switch on platform conditions. I couldn’t find
relevant documentation, and if someone could point me at an example it
would be kindly appreciated.


Eric G. Wolfe
email: eric.wolfe@cyclecomputing.com
cell: 304.942.3970
twitter: @atomic_penguin

Cycle Computing
Better Answers. Faster.

http://www.cyclecomputing.com
twitter: @cyclecomputing