Closed binlee1990 closed 10 years ago
So the script doesn't exit properly by itself? What do you mean by "stop the shell in the minion", what did you do to stop the shell?
We have had some issues with backgrounding processes in Salt, and I think they're related to the subprocess module in Python more than anything that Salt does. Would you mind trying to run the shell script via subprocess in a Python shell and see if it exits properly there?
Also, what version of salt are you using?
@basepi The version of salt is 0.17.2, I'm trying to upgrade it to the latest version. "stop the shell in the minion " means I kill -9 the process the shell produces.
I think it's the shell which produces a process that it's outputting message all the time, and salt can't recognize if the process has stopped.
My solution is add a redirect to a file in the shell
nohup ./flume-ng agent --conf ../conf --conf-file ../conf/custem.conf --name agent -Dflume.monitoring.type=com.suning.flume.monitor.AgentCenterServer >> ../logs/start_agent.log 2>&1 &
After that, salt can get the executed result without killing the process in the minion.
Yep, I think that's an issue with the Python subprocess
module, not anything salt can deal with. I've marked this as an upstream bug, and am going to go ahead and close it, since you've found a good workaround. Thanks again!
when I execute salt command, "salt 'sn*' state.sls flume.startup -t 10", it didn't return result until I stop shell in the minion.
startup.sls
start_agent.sh
Is there any problem that the shell has a "nohup" function?
when I stop the shell in the minion, master got the result: