Symptoms
How to debug APS 1.2 scripts on the sandbox?
Cause
Resolution
You need to find out the server where the scripts were provisioned. Find out the attribute assigned to the resource of your application in Applications -> MyApp -> "Resource Types" tab -> MyApp resource -> Provisioning Attributes
and find out the node with the same attribute in Infrastructure -> Hardware Nodes
Log on the server via ssh.
Find the script in the directory like below:
/usr/local/pem/APS/scripts/103/3.1.0-3/scripts/configure.php
You can add
'fwrite(SRTDERR, $myVar);'
to track the variables. Using fwrite will not break script output in POA.... $stderr = fopen('php://stderr', 'w'); fwrite($stderr, "\n my debug output\n"); fwrite($stderr, $myVar); ...
Now you can run script with specified system variables. The variables can be retrieved from /var/log/poa.debug.log on the management node:
[root@mn ~]# grep 'executing configuration script' /var/log/poa.debug.log [APS] executing configuration script for APS application with id 103:'SERVICE_ID=CloudFlareDomain' 'SETTINGS_app_instance_id=' 'SETTINGS_cf_email=test@test.com' 'SETTINGS_cf_enabled=on' 'SETTINGS_cf_password=*****' 'SETTINGS_cf_plus_enabled=on' 'SETTINGS_cf_sub_inclusion=example.com::www,blog,support' 'SETTINGS_customer_domain_name=select' 'SETTINGS_host_api_key=18b6fed6a2dc8f2b937dd9ab9ab' 'SETTINGS_poa_api_ip=172.11.5.181' 'SETTINGS_poa_api_port=8440' 'SETTINGS_poa_password=*****' 'SETTINGS_poa_user=admin' 'SETTINGS_subdomains_inc_list_1=www' 'SETTINGS_subscription_id=1000003' php -q 'configure.php' 'install'
So you can create bash script with system variable you got from log and run it. Please note that POA does not store the passwords in a plain text. You will need to replace the '*' values with actual passwords:
#!/bin/sh cd /usr/local/pem/APS/scripts/103/3.1.0-3/scripts 'SERVICE_ID=CloudFlareDomain' 'SETTINGS_app_instance_id=' 'SETTINGS_cf_email=test@test.com' 'SETTINGS_cf_enabled=on' 'SETTINGS_cf_password=myPassword' 'SETTINGS_cf_plus_enabled=on' 'SETTINGS_cf_sub_inclusion=example.com::www,blog,support' 'SETTINGS_customer_domain_name=select' 'SETTINGS_host_api_key=18b6fed6a2dc8f2b937dd9ab9ab' 'SETTINGS_poa_api_ip=172.11.5.181' 'SETTINGS_poa_api_port=8440' 'SETTINGS_poa_password=myPoaPassword' 'SETTINGS_poa_user=admin' 'SETTINGS_subdomains_inc_list_1=www' 'SETTINGS_subscription_id=1000003' php -q 'configure.php' 'install' php -q 'configure.php' 'install'
Now you can run bash script:
sh /usr/local/pem/APS/scripts/103/3.1.0-3/bash-script.sh <?xml version="1.0" encoding="UTF-8"?> <methodResponse><params><param><value><struct><member><name>result</name><value><array><data><value><i4>1000003</i4></value></data></array></value></member><member><name>status</name><value><i4>0</i4></value></member></struct></value></param></params></methodResponse> Array ( [i4] => 1000003 ) 0 => 1000003 my debug output