Closed landall closed 4 years ago
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/172143659
The labels on this github issue will be updated when the story is started.
You don't need those options. We use env variables to configure where PHP finds it's configuration files:
PHP_INI_SCAN_DIR=/home/vcap/app/php/etc/php.ini.d/
PHPRC=/home/vcap/app/php/etc
Run cf run-task php-info 'php --ini'
. This will run a task, and you should see the following in cf logs
.
2020-04-03T09:50:58.33-0400 [APP/TASK/fdc2304c/0] OUT Configuration File (php.ini) Path: /tmp/build/391e1b0b/binary-builder/ports/x86_64-linux-gnu/php7/7.3.16/lib
2020-04-03T09:50:58.33-0400 [APP/TASK/fdc2304c/0] OUT Loaded Configuration File: /home/vcap/app/php/etc/php.ini
2020-04-03T09:50:58.33-0400 [APP/TASK/fdc2304c/0] OUT Scan for additional .ini files in: /home/vcap/app/php/etc/php.ini.d/
2020-04-03T09:50:58.33-0400 [APP/TASK/fdc2304c/0] OUT Additional .ini files parsed: /home/vcap/app/php/etc/php.ini.d/extensions.ini
2020-04-03T09:50:58.36-0400 [APP/TASK/fdc2304c/0] OUT Exit status 0
It shows the ini files it's loaded, which is what's configured through the env variables.
See the docs on how to add additional php.ini configuration settings: https://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html#engine-configurations
Please note that if you are cf ssh
'ing into your app and running commands, the env variables mentioned above are not set by default. If you want that behavior, you can run cf ssh "<app>" -t -c "/tmp/lifecycle/launcher /home/vcap/app bash ''"
. This will use the launcher to bring up a shell which is configured exactly like your app or a task.
I run php in ADDITIONAL_PREPROCESS_CMDS, which do not set this two env vars. Maybe I should set them.
ADDITIONAL_PREPROCESS_CMDS
is deprecated. I would suggest you move the commands you're running there into a .profile
file. This is a script that will be automatically executed prior to your app starting, exactly like ADDITIONAL_PREPROCESS_CMDS
.
It's a bash script, so you can put in whatever commands you need to run. You don't need to worry about permissions on the script, just make sure it's in the root of your project (i.e. the same place from which you are running cf push
or where you have the cf push -p
/path set.
FYI, The ADDITIONAL_PREPROCESS_CMDS
option will go away in the next major version of the buildpack, which will be based on Cloud Native buildpacks.
ADDITIONAL_PREPROCESS_CMDS
is deprecated. I would suggest you move the commands you're running there into a.profile
file. This is a script that will be automatically executed prior to your app starting, exactly likeADDITIONAL_PREPROCESS_CMDS
.It's a bash script, so you can put in whatever commands you need to run. You don't need to worry about permissions on the script, just make sure it's in the root of your project (i.e. the same place from which you are running
cf push
or where you have thecf push -p
/path set.
Is there any docs about .profile file? It seems like a good thing to help me run some long-running workers in the background.
A bit about .profile
here -> https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile
It will work for background processes, but it's a little clunky. You have to manage to keep those background processes running & they all share the same memory limit, which can be tricky to manage.
There is a new way to do background processes which is a lot better: https://docs.cloudfoundry.org/devguide/multiple-processes.html. I would strongly suggest using this instead. It's currently listed as BETA, but that's just because the v3 APIs that it uses haven't been finalized yet (API could change). The feature itself is solid to use with your apps.
A bit about
.profile
here -> https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profileIt will work for background processes, but it's a little clunky. You have to manage to keep those background processes running & they all share the same memory limit, which can be tricky to manage.
There is a new way to do background processes which is a lot better: https://docs.cloudfoundry.org/devguide/multiple-processes.html. I would strongly suggest using this instead. It's currently listed as BETA, but that's just because the v3 APIs that it uses haven't been finalized yet (API could change). The feature itself is solid to use with your apps.
thanks, I get what to do now.
👍- I will close this out.
What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running
cf curl /v2/info && cf version
?{ "name": "IBM Cloud", "build": "v12.33.0", "support": "http://ibm.biz/bluemix-supportinfo", "version": 0, "description": "IBM Bluemix", "authorization_endpoint": "https://iam.cloud.ibm.com/cloudfoundry/login/us-south", "token_endpoint": "https://uaa.us-south.cf.cloud.ibm.com", "min_cli_version": null, "min_recommended_cli_version": null, "app_ssh_endpoint": "ssh.us-south.cf.cloud.ibm.com:2222", "app_ssh_host_key_fingerprint": "c7:1f:89:2a:62:3b:78:a9:08:c9:33:81:fb:39:26:da", "app_ssh_oauth_client": "ssh-proxy", "doppler_logging_endpoint": "wss://doppler.us-south.cf.cloud.ibm.com:443", "api_version": "2.146.0", "osbapi_version": "2.15", "user": "b9da9518-ed2f-4bc5-91ba-e9421af2c75d" }
cf version 6.46.1+4934877ec.2019-08-23
What version of the buildpack you are using?
Buildpack version 4.4.6
Can you add --with-config-file-path=PATH and --with-config-file-scan-dir=PATH to php compilation process. php (cli mode) cannot load php.ini and php.ini.d/* by default now. So it makes some trouble when i want to run some background php tasks.