工头条件 运行 进程
Foreman conditional running processes
我有一个带有这样 Procfile 的工头应用程序
web: bundle exec rails s
custom_process: bundle exec rake custom:process
faking_custom_process: bundle exec rake custom:faking_process
而我想运行custom_process
或faking custom_process
取决于我的需要:
foreman start # run web & custom_process
FAKING_PROCESS # run web & faking_custom_process
是的,我知道 运行ning 这样的能力 foreman start -c faking_custom_process=0
,但这比我想象的要难,对吧?
foreman 中没有选项可以跳过一个过程。如果您想 运行 其他进程,我认为您也需要扩展开始调用以执行不同的操作。否则你只是告诉它 运行 faking_custom_process
的零个副本,没有别的:
foreman start -m web=1,custom_process=1,faking_custom_process=0
或伪造版本:
foreman start -m web=1,custom_process=0,faking_custom_process=1
你当然可以编写脚本,所以你有两个脚本 运行ning 那些不同的版本。
另一种方法是使用环境中的变量打开或关闭伪装(我不相信它更容易,但它是一种替代方法):
web: bundle exec rails d
custom_process: PROCESS=$FAKING"process" && bundle exec rake custom:$PROCESS
正常的 foreman start
将只是 运行 bundle exec rake custom:process
。
对于伪造的等价物,你可以这样做:
export FAKING="faking_"
这意味着从那时起 foreman start
它将改为调用 bundle exec rake custom:faking_process
。
您可以 return 通过清除 FAKING
变量来进入正常过程:
export FAKING=
您当然也可以将其封装到 shell 脚本中。
您可以使用 .profile 来存储 foreman start
的默认选项:
concurrency: web=1,custom_process=1,faking_custom_process=0
或使用快捷方式:
concurrency: all=1,faking_custom_process=0
然后您覆盖此默认选项以切换到假进程:
foreman start -c all=1,custom_process=0
我有一个带有这样 Procfile 的工头应用程序
web: bundle exec rails s
custom_process: bundle exec rake custom:process
faking_custom_process: bundle exec rake custom:faking_process
而我想运行custom_process
或faking custom_process
取决于我的需要:
foreman start # run web & custom_process
FAKING_PROCESS # run web & faking_custom_process
是的,我知道 运行ning 这样的能力 foreman start -c faking_custom_process=0
,但这比我想象的要难,对吧?
foreman 中没有选项可以跳过一个过程。如果您想 运行 其他进程,我认为您也需要扩展开始调用以执行不同的操作。否则你只是告诉它 运行 faking_custom_process
的零个副本,没有别的:
foreman start -m web=1,custom_process=1,faking_custom_process=0
或伪造版本:
foreman start -m web=1,custom_process=0,faking_custom_process=1
你当然可以编写脚本,所以你有两个脚本 运行ning 那些不同的版本。
另一种方法是使用环境中的变量打开或关闭伪装(我不相信它更容易,但它是一种替代方法):
web: bundle exec rails d
custom_process: PROCESS=$FAKING"process" && bundle exec rake custom:$PROCESS
正常的 foreman start
将只是 运行 bundle exec rake custom:process
。
对于伪造的等价物,你可以这样做:
export FAKING="faking_"
这意味着从那时起 foreman start
它将改为调用 bundle exec rake custom:faking_process
。
您可以 return 通过清除 FAKING
变量来进入正常过程:
export FAKING=
您当然也可以将其封装到 shell 脚本中。
您可以使用 .profile 来存储 foreman start
的默认选项:
concurrency: web=1,custom_process=1,faking_custom_process=0
或使用快捷方式:
concurrency: all=1,faking_custom_process=0
然后您覆盖此默认选项以切换到假进程:
foreman start -c all=1,custom_process=0