How to fail a ShellCommandActivity on AWS Data pipeline

只谈情不闲聊 提交于 2019-12-11 15:48:14

问题


I am using AWS Data Pipeline and specifically the ShellCommandActivity object. This object calls a python script which extracts data via ftp, etc. There exists a chance that the file may not exist or the file may be of the wrong type and the pipeline can no longer run. If the python script errors out, or fails, the ShellCommandActivity object still gets marked as Finished, when I"m trying to get it to Failure. I have tried, in python, doing sys.exit(500) on failure, but the object still gets marked as Finished. How can I fail a ShellCommandActivity from a python script?


回答1:


You could try something along the lines of:

cd $INPUT1_STAGING_DIR
chmod +x #{myBashScript}
bash #{myBashScript}
EXIT_CODE=$?
mv $INPUT1_STAGING_DIR/output $OUTPUT1_STAGING_DIR
exit $EXIT_CODE

The data pipeline will probably use the exit code of the last command. I have not tested this though.



来源:https://stackoverflow.com/questions/49302814/how-to-fail-a-shellcommandactivity-on-aws-data-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!