我一直在尝试将我在bash中运行的命令转换为使用Phing启动resque使用者,但是在执行php命令之前我找不到设置环境变量的方法。
这是我试图转换的命令:
APPLICATION_ENV=dev VVERBOSE=1 QUEUE=myqueue APP_INCLUDE=app/cli/bootstrap.php php composer/chrisboulton/php-resque/resque.php
我试过了:
<!-- Resque start consumer -->
<target name="start_resque_consumer" description="Spans a resque consumer">
<property environment="APPLICATION_ENV" value="dev"/>
<property environment="VVERBOSE" value="1"/>
<property environment="QUEUE" value="myqueue"/>
<property environment="APP_INCLUDE" value="${project.basedir}/app/cli/bootstrap.php"/>
<exec executable="php" checkreturn="true" passthru="true" dir="${project.basedir}/composer/chrisboulton/php-resque">
<arg line="resque.php"/>
</exec>
</target>
和
<!-- Resque start consumer -->
<target name="start_resque_consumer" description="Spans a resque consumer">
<exec executable="APPLICATION_ENV=dev
VVERBOSE=1
QUEUE=myqueue
APP_INCLUDE=${project.basedir}/app/cli/bootstrap.php
php" checkreturn="true" passthru="true" dir="${project.basedir}/composer/chrisboulton/php-resque">
<arg line="resque.php"/>
</exec>
</target>
任何想法我怎样才能使这项工作?甚至可以使用Phing设置环境变量吗?
答案 0 :(得分:0)
在脚本之前使用env
命令。
<!-- Here are the initial data, under .gitignore -->
<property file="build/secret/local.ini"/>
<!-- Let's create some shortcuts -->
<property name="local.mysql.connect" value="-h${local.mysql.host} -P${local.mysql.port} -u${local.mysql.user}"/>
<property name="local.mysql.env" value="env MYSQL_PWD=${local.mysql.password}"/>
<target name="some_target">
<!-- Tens of them. "The password in command line" warning finally silenced. It can be put in cron ! -->
<exec
command="${local.mysql.env} mysql ${local.mysql.connect} ${local.mysql.database.target} < ./sql/some_script.sql"
/>
</target>
答案 1 :(得分:-1)
试试这个:
<target name="start_resque_consumer" description="Spans a resque consumer">
<exec executable="php" checkreturn="true" passthru="true" dir="${project.basedir}/composer/chrisboulton/php-resque">
<arg value="${project.basedir}/composer/chrisboulton/php-resque/resque.php" />
<env key="VVERBOSE" value="1" />
<env key="QUEUE" value="myqueue" />
<env key="APP_INCLUDE" value="${project.basedir}/app/cli/bootstrap.php" />
</exec>
</target>