2017-02-15 70 views
2

目的:設置彈性魔豆環境變量

我想從預部署部署掛鉤

嘗試設置部署時間戳作爲環境變量:

files: 
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_deploy_time.sh": 
    mode: "000755" 
    owner: root 
    group: root 
    content: | 
     #!/bin/bash 
     export DEPLOY_TIME=`date +%s` 

DEPLOY_TIME dosen't get set。


最糟糕的情況我可以將部署時間寫入隨機文本文件。但是,由於我的應用程序將頻繁地讀取此變量,因此這不是最佳選擇。

+0

EBS ==彈性塊存儲,而不是彈性Beanstalk。 –

+0

哎呦,我編輯了標題 –

+0

你可以嘗試追加變量到'/ etc/profile.d/eb_envvars.sh',其中EB變量的其餘部分被設置。 – Brian

回答

0

我剛剛結束了剛寫入時間戳一個隨機文件

.ebextensions/00_set_deploy_time.sh

files: 
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/00_set_deploy_time.sh": 
    mode: "000755" 
    owner: root 
    group: root 
    content: | 
     #!/bin/bash 
     touch /var/app/deploy_timestamp.txt 
     echo `date +%s` > /var/app/deploy_timestamp.txt 

ruby這樣閱讀:

deploy_time = Time.at(File.read('/var/app/deploy_timestamp.txt').to_i)