Closed innovia closed 9 years ago
you should not use shell script and daemonize true
. because it is not properly monitored. shell script produce tree of processes, ./startVagrantServer.sh -> node server.js, and eye whould monitor only ./startVagrantServer.sh, and send kill to it, which is not correct. (because after kill, node server.js still be alive).
Solutions:
daemonize true
and do daemonization for node server.js by hands.use_leaf_child true
, this should solve situation with shell fork tree, but it is experimental.there's actually a trigger for before start? can i use back ticks there like so?
trigger :transition, :to => :before_start, :do => -> {
debug "creating sqs queues"
`/usr/local/bin/node scripts/createQueues.js Vagrant`
debug "listing sqs queues"
`/usr/local/bin/node scripts/listQueues.js`
debug "creatign dynamodb tables"
`/usr/local/bin/node scripts/createDynamoDBTable.js`
`/usr/bin/mysql -u root -h localhost --password=123456 < scripts/createMysqlTables.sql`
`/usr/local/bin/node scripts/initializeDynamoBot.js`
}
this should work:
trigger :transition, to: :starting, do: -> {
cmd = "touch /tmp/111"
res = process.execute(cmd, process.config.merge(:timeout => 10.seconds))
info "executing `#{cmd}` with result: #{res}"
}
backticks is not good, because it can block the process actor.
Thank you so much for always being prompt and helpful I really appreciate your help and I think eye is an excellent product!
Thanks for the info I'll give it a try tomorrow
Thank you that resolved the issue!
in master i add helpers execute_async, execute_sync:
trigger :transition, to: :starting, do: -> {
process.execute_sync "touch /tmp/111"
process.execute_sync "sleep 2", :timeout => 1
process.execute_async "sleep 2"
}
There's an issue when you pass more than one param to cmd, like so
cmd = "/usr/bin/mysql -uroot -h127.0.0.1 -p123456 < scripts/createMysqlTables.sql"
only mysql triggered
or for example
cmd = "mv /a/b/c/file1 /d/"
mv fails, again more than one param
for me this is ok
+
+ trigger :transition, to: :starting, do: -> {
+ process.execute_sync "cp trash.log /tmp/"
+ }
12.11.2014 17:14:53 INFO -- [test:samples:sample1] execute_sync
cp trash.log /tmp/with res: {:pid=>5137, :exitstatus=>0}
file copied
you also can move all your commands into shell script, and run only it.
Hi Kostya
I have tried all day but i m not getting to a solution
my issue is that i have a few process
elasticMQ (Amazon local SQS) simple queue service Local Amazon DynamoDB (database) server.js
before running server.js i have to create tables and queues on every restart since they are not persistant I have to create the queues (single command) I have to create the tables (single command)
so i tried with dependencies and setting up transitions to up with back ticks to run the commands but its not creating the tables and queues
i ended up running a bash wrapper that does all of that and start server.js at the end
but it wasn't monitoing the child process so i've added monitoring_children which gets the child but doesn't transfer the stop command (kill -2 {PID}) to the child and so i have left with a running process unattached to eye
can you please help me out here?
here's the wrapper
here's my eye config