1

aws データ パイプラインで bash スクリプトを使用して ruby​​ ファイルを呼び出す必要があります

コマンド引数でシェルコマンドアクティビティを使用してみました

jsonファイル

> {
>       "objects": [
>         {
>           "terminateAfter": "1 Hours",
>           "id": "ResourceId5",
>           "schedule": {
>             "ref": "ScheduleId4"
>           },
>           "name": "Resource1",
>           "logUri": "s3://pipeline_test/output1/",
>           "type": "Ec2Resource"
>         },
>         {
>           "id": "ActivityId1",
>           "schedule": {
>             "ref": "ScheduleId4"
>           },
>           "name": "Shell",
>           "command": "bash -lc 'cd ~/pipeline_test/inputs/ && ruby sample.rb'", # bash command script path for ruby file
>           "runsOn": {
>             "ref": "ResourceId5"
>           },
>           "type": "ShellCommandActivity",
>           "output": {
>             "ref": "DataNodeId3"
>           }
>         },
>         {
>           "id": "DataNodeId3",
>           "schedule": {
>             "ref": "ScheduleId4"
>           },
>           "directoryPath": "s3://pipeline_test/output/",
>           "name": "Output",
>           "type": "S3DataNode"
>         },
>         {
>           "id": "Default",
>           "scheduleType": "timeseries",
>           "name": "Default",
>           "role": "DataPipelineDefaultRole",
>           "resourceRole": "DataPipelineDefaultResourceRole"
>         },
>         {
>           "id": "ScheduleId4",
>           "startDateTime": "2013-08-01T00:00:00",
>           "name": "schedule",
>           "type": "Schedule",
>           "period": "20 Minutes",
>           "endDateTime": "2013-08-03T00:00:00"
>         }
>       ]
>     }

sample.rb

f = File.open('text.txt', 'a+')
old_out = $stdout
$stdout = f
puts "Start time #{Time.now}"
puts "Welcome"
puts "End time #{Time.now}"
f.close

s3 パスの指定方法がわかりません ("command": "bash -lc 'cd ~/pipeline_test(bucket_name)/inputs/ && ruby​​ sample.rb'", )

私はスクリプト終了ステータス1を取得しています

それを解決するために私を助けてください。

4

1 に答える 1

2

これを実現する 1 つの方法は、"sample.rb" を呼び出す以下のようなラッパー シェル スクリプトを用意することです。

$INPUT1_STAGING_DIR/sample.rb >> $OUTPUT1_STAGING_DIR/output.txt

「コマンド」を指定する代わりに、S3 のシェル スクリプトを指す「スクリプト URI」を指定できます。

また、「Stage = true」を有効にして、入力データノードが sample.rb スクリプトを含む s3 フォルダーを指すようにする必要があります。

ステージングの詳細については、こちらをご覧ください

sample.rb を変更し、"text.txt" の代わりに "$INPUT1_STAGING_DIR/text.txt" のような適切なパスを指定する必要があります。

お役に立てれば。

于 2013-09-12T18:47:13.807 に答える