pantheon-systems / terminus

The Pantheon CLI — a standalone utility for performing operations on the Pantheon Platform
https://pantheon.io
Other
317 stars 196 forks source link

Running Terminus programmatically from node fails. #1677

Open generalredneck opened 7 years ago

generalredneck commented 7 years ago

Just a quick note... This is an issue with Terminus >=1.1.0. Before that, using 1.0.0 worked (and still works) beautifully. I may try a git bisect between 1.0.0 and 1.1.0 later.

Expected behavior

Terminus should behave identically whether run as a specific user programmatically or via commandline.

Actual behavior

Running terminus in aquifer causes the command to fail after it makes all the requests after

[warning] This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.

At this point it just Hangs forever... Some commands actually go and do what they were expected to do but never exit (such as terminus import:database), but all the terminus drush commands just hang without doing anything (ex terminus -vvv drush craft-council.sprint -- updb --yes)

In fact here is the output of that command using 1.1.1

[debug] Plugin Autoload: %dir is a Terminus source file.
[debug] #### REQUEST ####
Headers: {"Content-type":"application\/json","User-Agent":"Terminus\/1.1.2 (php_version=5.6.30&script=bin\/terminus)","Authorization":"**HIDDEN**"}
URI: https://terminus.pantheon.io:443/api/site-names/craft-council
Method: GET
Body: null
[debug] #### RESPONSE ####
Headers: {"Server":["nginx"],"Date":["Wed, 05 Apr 2017 18:02:03 GMT"],"Content-Type":["application\/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"X-Pantheon-Trace-Id":["f900f3e0-1a29-11e7-b49b-4decb426dab4"],"X-Frame-Options":["deny"],"Access-Control-Allow-Methods":["GET"],"Access-Control-Allow-Headers":["Origin, Content-Type, Accept"],"Cache-Control":["private, max-age=0, no-cache, no-store"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Strict-Transport-Security":["max-age=31536000"]}
Data: {"id":"f1dfea7b-8490-435f-823e-d8d4efdcee57","name":"craft-council"}
Status Code: 200
[debug] #### REQUEST ####
Headers: {"Content-type":"application\/json","User-Agent":"Terminus\/1.1.2 (php_version=5.6.30&script=bin\/terminus)","Authorization":"**HIDDEN**"}
URI: https://terminus.pantheon.io:443/api/sites/f1dfea7b-8490-435f-823e-d8d4efdcee57?site_state=true
Method: GET
Body: null
[debug] #### RESPONSE ####
Headers: {"Server":["nginx"],"Date":["Wed, 05 Apr 2017 18:02:03 GMT"],"Content-Type":["application\/json"],"Content-Length":["3732"],"Connection":["keep-alive"],"X-Pantheon-Trace-Id":["f9321600-1a29-11e7-b9e3-81bbe73778ed"],"X-Frame-Options":["deny"],"Access-Control-Allow-Methods":["GET"],"Access-Control-Allow-Headers":["Origin, Content-Type, Accept"],"Cache-Control":["private, max-age=0, no-cache, no-store"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Strict-Transport-Security":["max-age=31536000"]}
Data: {"cost":130,"created":1457020727,"created_by_user_id":"851f4929-a748-4652-912c-9013f1f82b9b","drush_version":8,"framework":"drupal8","holder_id":"915a8c8b-2941-40a7-a21a-a55b4586ba37","holder_type":"user","instrument":"20df8da1-8fbd-8e73-e657-1ed7772ace2f","last_code_push":{"timestamp":"2017-04-03T17:01:49","user_uuid":"dff3993a-e29d-4562-aeb2-36a0cc434d8e"},"name":"craft-council","organization":"15589f65-d81b-4ea5-add4-f76cffb9eedc","owner":"915a8c8b-2941-40a7-a21a-a55b4586ba37","php_version":55,"preferred_zone":"chios","purchased_at":1468531291,"service_level":"pro","upstream":{"url":"git:\/\/github.com\/pantheon-systems\/drops-8.git","product_id":"8a129104-9d37-4082-aaf8-e6f31154644e","branch":"master"},"label":"Craft Council","id":"f1dfea7b-8490-435f-823e-d8d4efdcee57","holder":{"profile":{"utm_term":"","invites_to_nonuser":2,"utm_content":"\/","experiments":{"welcome_video":"not_shown"},"full_name":"Jason Samuels","utm_device":"","initial_identity_strategy":null,"google_adwords_pushed_code_do_send":null,"utm_campaign":"pantheon.io (organic)","tracking_first_site_create":1442528504,"google_adwords_paid_for_site_do_send":null,"verify":"59d6834f97ea2ae6c5fa02f64c04a7ee","tracking_first_code_push":1442605310,"google_adwords_account_registered_sent":1442528198,"invites_to_user":4,"utm_medium":"SEM","job_function":"owner","tracking_first_workflow_in_live":1442528854,"google_adwords_account_registered_do_send":null,"tracking_first_team_invite":1444332449,"firstname":"Jason","invites_to_site":6,"lastname":"Samuels","pda_campaign":null,"copyCodeUpdatePhp":true,"utm_source":"https:\/\/www.google.com\/","google_adwords_pushed_code_sent":1442605904,"last-org-spinup":"e584858d-c134-416e-b075-b69453b57e6e","web_services_business":null,"initial_identity_name":null,"guilty_of_abuse":null,"invites_sent":6,"tracking_first_site_upgrade":1468531289,"google_adwords_paid_for_site_sent":1468531293,"modified":1442528194,"maxdevsites":4,"lead_type":"","organization":"American Craft Council"},"id":"915a8c8b-2941-40a7-a21a-a55b4586ba37","email":"jsamuels@craftcouncil.org"},"settings":{"allow_domains":true,"max_num_cdes":10,"stunnel":false,"cost":130,"owner":"915a8c8b-2941-40a7-a21a-a55b4586ba37","secure_runtime_access":false,"pingdom":0,"allow_indexserver":false,"created_by_user_id":"851f4929-a748-4652-912c-9013f1f82b9b","failover_appserver":0,"cacheserver":1,"support_plan":"regular_support","appserver":1,"on_server_development":false,"drush_version":8,"label":"Craft Council","instrument":"20df8da1-8fbd-8e73-e657-1ed7772ace2f","number_allow_domains":200,"allow_read_slaves":false,"indexserver":1,"php_version":55,"php_channel":"stable","allow_cacheserver":false,"ssl_enabled":null,"min_backups":0,"service_level":"pro","dedicated_ip":null,"dbserver":1,"purchased_at":1468531291,"framework":"drupal8","upstream":{"url":"git:\/\/github.com\/pantheon-systems\/drops-8.git","product_id":"8a129104-9d37-4082-aaf8-e6f31154644e","branch":"master"},"guilty_of_abuse":null,"preferred_zone":"chios","pingdom_chance":0,"holder_id":"915a8c8b-2941-40a7-a21a-a55b4586ba37","name":"craft-council","created":1457020727,"max_backups":7,"holder_type":"user","replica_verification_strategy":"pt-heartbeat","organization":"15589f65-d81b-4ea5-add4-f76cffb9eedc","pingdom_manually_enabled":false,"last_code_push":{"timestamp":"2017-04-03T17:01:49","user_uuid":"dff3993a-e29d-4562-aeb2-36a0cc434d8e"}},"base_domain":null,"attributes":{"label":"Craft Council"},"add_ons":[{"id":"NewRelic","label":"New Relic"}]}
Status Code: 200
[debug] #### REQUEST ####
Headers: {"Content-type":"application\/json","User-Agent":"Terminus\/1.1.2 (php_version=5.6.30&script=bin\/terminus)","Authorization":"**HIDDEN**"}
URI: https://terminus.pantheon.io:443/api/sites/f1dfea7b-8490-435f-823e-d8d4efdcee57/environments
Method: GET
Body: null
[debug] #### RESPONSE ####
Headers: {"Server":["nginx"],"Date":["Wed, 05 Apr 2017 18:02:04 GMT"],"Content-Type":["application\/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"X-Pantheon-Trace-Id":["f9a34e60-1a29-11e7-b49b-4decb426dab4"],"X-Frame-Options":["deny"],"Access-Control-Allow-Methods":["GET"],"Access-Control-Allow-Headers":["Origin, Content-Type, Accept"],"Cache-Control":["private, max-age=0, no-cache, no-store"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Strict-Transport-Security":["max-age=31536000"]}
Data: {"test":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"environment_created":1457020729,"dns_zone":"pantheonsite.io","randseed":"1W3UAKTGLF661CXGFSMF5SL07CS0EM7J","target_ref"

:"refs\/tags\/pantheon_test_59","maintenance":{"enabled":false},"lock":{"username":null,"password":null,"locked":false},"target_commit":"d57d1aa8e6dabb34d05297dc796eb18041a0578c","styx_cluster":"styx-03.pantheon.io"},"dev":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"watchers":1,"diffstat":{},"on_server_development":false,"environment_created":1457020727,"dns_zone":"pantheonsite.io","randseed":"4RW8T0Q4HSO2SCTFJTRLO8G96N9XFXUN","target_commit":"d57d1aa8e6dabb34d05297dc796eb18041a0578c","target_ref":"refs\/heads\/master","lock":{"username":null,"password":null,"locked":false},"environment_variables":{},"styx_cluster":"styx-01.pantheon.io"},"sprint":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"watchers":1,"diffstat":{},"on_server_development":false,"environment_created":1459810763,"dns_zone":"pantheonsite.io","randseed":"L43F1ZK8X41MBF7XTD50E8FY3KD4UQIC","target_commit":"3d2ea38f58dec252d23d30431c59ec4cd24402c9","target_ref":"refs\/heads\/sprint","lock":{"username":null,"password":null,"locked":false},"environment_variables":{},"styx_cluster":"styx-01.pantheon.io"},"sandbox":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"environment_created":1491233939,"dns_zone":"pantheonsite.io","randseed":"XG5AIHC3ERRO3AE4TZOEPWM2BL12T573","target_ref":"refs\/heads\/sandbox","lock":{"username":null,"password":null,"locked":false},"target_commit":"2c494711a520425973925c49e624c2b8d4d47b77","styx_cluster":"styx-01.pantheon.io"},"eric":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"diffstat":{},"on_server_development":false,"environment_created":1477931292,"dns_zone":"pantheonsite.io","randseed":"40MXU77CN0TA03JD1W4G3ZBM1GSRWSIU","target_commit":"2c904b3b847fd50bc8c502ea5096c614ba65c1f6","target_ref":"refs\/heads\/eric","lock":{"username":null,"password":null,"locked":false},"environment_variables":{},"styx_cluster":"styx-01.pantheon.io"},"live":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"dedicated_ip":true,"environment_created":1457020731,"dns_zone":"pantheonsite.io","randseed":"Q8S70T2WSRO8I2YYY6XJO8MTI64VOPUK","number_allow_domains":2,"lock":{"username":null,"password":null,"locked":false},"target_commit":"d57d1aa8e6dabb34d05297dc796eb18041a0578c","ssl_enabled":true,"styx_cluster":"styx-03.pantheon.io","target_ref":"refs\/tags\/pantheon_live_38"}}
Status Code: 200
[warning] This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.

Here is the output of the same command run on commandline (not from aquifer)

 [debug] Plugin Autoload: %dir is a Terminus source file.
 [debug] #### REQUEST ####
Headers: {"Content-type":"application\/json","User-Agent":"Terminus\/1.1.1 (php_version=5.6.30&script=bin\/terminus)","Authorization":"**HIDDEN**"}
URI: https://terminus.pantheon.io:443/api/site-names/craft-council
Method: GET
Body: null
 [debug] #### RESPONSE ####
Headers: {"Server":["nginx"],"Date":["Wed, 05 Apr 2017 18:27:42 GMT"],"Content-Type":["application\/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"X-Pantheon-Trace-Id":["8e4a8b70-1a2d-11e7-94af-e16599df916f"],"X-Frame-Options":["deny"],"Access-Control-Allow-Methods":["GET"],"Access-Control-Allow-Headers":["Origin, Content-Type, Accept"],"Cache-Control":["private, max-age=0, no-cache, no-store"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Strict-Transport-Security":["max-age=31536000"]}
Data: {"id":"f1dfea7b-8490-435f-823e-d8d4efdcee57","name":"craft-council"}
Status Code: 200
 [debug] #### REQUEST ####
Headers: {"Content-type":"application\/json","User-Agent":"Terminus\/1.1.1 (php_version=5.6.30&script=bin\/terminus)","Authorization":"**HIDDEN**"}
URI: https://terminus.pantheon.io:443/api/sites/f1dfea7b-8490-435f-823e-d8d4efdcee57?site_state=true
Method: GET
Body: null
 [debug] #### RESPONSE ####
Headers: {"Server":["nginx"],"Date":["Wed, 05 Apr 2017 18:27:42 GMT"],"Content-Type":["application\/json"],"Content-Length":["3732"],"Connection":["keep-alive"],"X-Pantheon-Trace-Id":["8e7767d0-1a2d-11e7-94af-e16599df916f"],"X-Frame-Options":["deny"],"Access-Control-Allow-Methods":["GET"],"Access-Control-Allow-Headers":["Origin, Content-Type, Accept"],"Cache-Control":["private, max-age=0, no-cache, no-store"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Strict-Transport-Security":["max-age=31536000"]}
Data: {"cost":130,"created":1457020727,"created_by_user_id":"851f4929-a748-4652-912c-9013f1f82b9b","drush_version":8,"framework":"drupal8","holder_id":"915a8c8b-2941-40a7-a21a-a55b4586ba37","holder_type":"user","instrument":"20df8da1-8fbd-8e73-e657-1ed7772ace2f","last_code_push":{"timestamp":"2017-04-03T17:01:49","user_uuid":"dff3993a-e29d-4562-aeb2-36a0cc434d8e"},"name":"craft-council","organization":"15589f65-d81b-4ea5-add4-f76cffb9eedc","owner":"915a8c8b-2941-40a7-a21a-a55b4586ba37","php_version":55,"preferred_zone":"chios","purchased_at":1468531291,"service_level":"pro","upstream":{"url":"git:\/\/github.com\/pantheon-systems\/drops-8.git","product_id":"8a129104-9d37-4082-aaf8-e6f31154644e","branch":"master"},"label":"Craft Council","id":"f1dfea7b-8490-435f-823e-d8d4efdcee57","holder":{"profile":{"utm_term":"","invites_to_nonuser":2,"utm_content":"\/","experiments":{"welcome_video":"not_shown"},"full_name":"Jason Samuels","utm_device":"","initial_identity_strategy":null,"google_adwords_pushed_code_do_send":null,"utm_campaign":"pantheon.io (organic)","tracking_first_site_create":1442528504,"google_adwords_paid_for_site_do_send":null,"verify":"59d6834f97ea2ae6c5fa02f64c04a7ee","tracking_first_code_push":1442605310,"google_adwords_account_registered_sent":1442528198,"invites_to_user":4,"utm_medium":"SEM","job_function":"owner","tracking_first_workflow_in_live":1442528854,"google_adwords_account_registered_do_send":null,"tracking_first_team_invite":1444332449,"firstname":"Jason","invites_to_site":6,"lastname":"Samuels","pda_campaign":null,"copyCodeUpdatePhp":true,"utm_source":"https:\/\/www.google.com\/","google_adwords_pushed_code_sent":1442605904,"last-org-spinup":"e584858d-c134-416e-b075-b69453b57e6e","web_services_business":null,"initial_identity_name":null,"guilty_of_abuse":null,"invites_sent":6,"tracking_first_site_upgrade":1468531289,"google_adwords_paid_for_site_sent":1468531293,"modified":1442528194,"maxdevsites":4,"lead_type":"","organization":"American Craft Council"},"id":"915a8c8b-2941-40a7-a21a-a55b4586ba37","email":"jsamuels@craftcouncil.org"},"settings":{"allow_domains":true,"max_num_cdes":10,"stunnel":false,"cost":130,"owner":"915a8c8b-2941-40a7-a21a-a55b4586ba37","secure_runtime_access":false,"pingdom":0,"allow_indexserver":false,"created_by_user_id":"851f4929-a748-4652-912c-9013f1f82b9b","failover_appserver":0,"cacheserver":1,"support_plan":"regular_support","appserver":1,"on_server_development":false,"drush_version":8,"label":"Craft Council","instrument":"20df8da1-8fbd-8e73-e657-1ed7772ace2f","number_allow_domains":200,"allow_read_slaves":false,"indexserver":1,"php_version":55,"php_channel":"stable","allow_cacheserver":false,"ssl_enabled":null,"min_backups":0,"service_level":"pro","dedicated_ip":null,"dbserver":1,"purchased_at":1468531291,"framework":"drupal8","upstream":{"url":"git:\/\/github.com\/pantheon-systems\/drops-8.git","product_id":"8a129104-9d37-4082-aaf8-e6f31154644e","branch":"master"},"guilty_of_abuse":null,"preferred_zone":"chios","pingdom_chance":0,"holder_id":"915a8c8b-2941-40a7-a21a-a55b4586ba37","name":"craft-council","created":1457020727,"max_backups":7,"holder_type":"user","replica_verification_strategy":"pt-heartbeat","organization":"15589f65-d81b-4ea5-add4-f76cffb9eedc","pingdom_manually_enabled":false,"last_code_push":{"timestamp":"2017-04-03T17:01:49","user_uuid":"dff3993a-e29d-4562-aeb2-36a0cc434d8e"}},"base_domain":null,"attributes":{"label":"Craft Council"},"add_ons":[{"id":"NewRelic","label":"New Relic"}]}
Status Code: 200
 [debug] #### REQUEST ####
Headers: {"Content-type":"application\/json","User-Agent":"Terminus\/1.1.1 (php_version=5.6.30&script=bin\/terminus)","Authorization":"**HIDDEN**"}
URI: https://terminus.pantheon.io:443/api/sites/f1dfea7b-8490-435f-823e-d8d4efdcee57/environments
Method: GET
Body: null
 [debug] #### RESPONSE ####
Headers: {"Server":["nginx"],"Date":["Wed, 05 Apr 2017 18:27:43 GMT"],"Content-Type":["application\/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"X-Pantheon-Trace-Id":["8eb53420-1a2d-11e7-b9e3-81bbe73778ed"],"X-Frame-Options":["deny"],"Access-Control-Allow-Methods":["GET"],"Access-Control-Allow-Headers":["Origin, Content-Type, Accept"],"Cache-Control":["private, max-age=0, no-cache, no-store"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Strict-Transport-Security":["max-age=31536000"]}
Data: {"test":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"environment_created":1457020729,"dns_zone":"pantheonsite.io","randseed":"1W3UAKTGLF661CXGFSMF5SL07CS0EM7J","target_ref":"refs\/tags\/pantheon_test_59","maintenance":{"enabled":false},"lock":{"username":null,"password":null,"locked":false},"target_commit":"d57d1aa8e6dabb34d05297dc796eb18041a0578c","styx_cluster":"styx-03.pantheon.io"},"dev":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"watchers":1,"diffstat":{},"on_server_development":false,"environment_created":1457020727,"dns_zone":"pantheonsite.io","randseed":"4RW8T0Q4HSO2SCTFJTRLO8G96N9XFXUN","target_commit":"d57d1aa8e6dabb34d05297dc796eb18041a0578c","target_ref":"refs\/heads\/master","lock":{"username":null,"password":null,"locked":false},"environment_variables":{},"styx_cluster":"styx-01.pantheon.io"},"sprint":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"watchers":1,"diffstat":{},"on_server_development":false,"environment_created":1459810763,"dns_zone":"pantheonsite.io","randseed":"L43F1ZK8X41MBF7XTD50E8FY3KD4UQIC","target_commit":"3d2ea38f58dec252d23d30431c59ec4cd24402c9","target_ref":"refs\/heads\/sprint","lock":{"username":null,"password":null,"locked":false},"environment_variables":{},"styx_cluster":"styx-01.pantheon.io"},"sandbox":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"environment_created":1491233939,"dns_zone":"pantheonsite.io","randseed":"XG5AIHC3ERRO3AE4TZOEPWM2BL12T573","target_ref":"refs\/heads\/sandbox","lock":{"username":null,"password":null,"locked":false},"target_commit":"2c494711a520425973925c49e624c2b8d4d47b77","styx_cluster":"styx-01.pantheon.io"},"eric":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"diffstat":{},"on_server_development":false,"environment_created":1477931292,"dns_zone":"pantheonsite.io","randseed":"40MXU77CN0TA03JD1W4G3ZBM1GSRWSIU","target_commit":"2c904b3b847fd50bc8c502ea5096c614ba65c1f6","target_ref":"refs\/heads\/eric","lock":{"username":null,"password":null,"locked":false},"environment_variables":{},"styx_cluster":"styx-01.pantheon.io"},"live":{"quicksilver_configuration":{"sync_code":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]},"deploy":{"after":[{"type":"webphp","description":"Log to New Relic","script":"private\/scripts\/new_relic_deploy.php"}]}},"dedicated_ip":true,"environment_created":1457020731,"dns_zone":"pantheonsite.io","randseed":"Q8S70T2WSRO8I2YYY6XJO8MTI64VOPUK","number_allow_domains":2,"lock":{"username":null,"password":null,"locked":false},"target_commit":"d57d1aa8e6dabb34d05297dc796eb18041a0578c","ssl_enabled":true,"styx_cluster":"styx-03.pantheon.io","target_ref":"refs\/tags\/pantheon_live_38"}}
Status Code: 200
 [warning] This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.
The following module is missing from the file system: acc_magazine     [warning]
bootstrap.inc:236
The following module is missing from the file system: standard         [warning]
bootstrap.inc:236
No database updates required                                           [success]
 [notice] Command: craft-council.sprint -- drush updb [Exit: 0]

A quick diff of the 2 shows this: image

Just in case you are curious... this is what the commands look like ran in terminus 1.0.0

[debug] #### REQUEST ####
Headers: {"User-Agent":"Terminus\/1.0.0 (php_version=5.6.30&script=bin\/terminus)","Content-type":"application\/json","Authorization":"Bearer 451758e4-d187-4ead-a7ea-a9077b3557d5:b894f536-188f-11e7-bcd8-bc764e1022a9:Dy8JzWdfISTLFrDk014pN"}
URI: https://terminus.pantheon.io:443/api/site-names/craft-council
Method: GET
Body:
[debug] #### RESPONSE ####
Headers: {headers}
Data: {data}
Status Code: 200
[debug] #### REQUEST ####
Headers: {"User-Agent":"Terminus\/1.0.0 (php_version=5.6.30&script=bin\/terminus)","Content-type":"application\/json","Authorization":"Bearer 451758e4-d187-4ead-a7ea-a9077b3557d5:b894f536-188f-11e7-bcd8-bc764e1022a9:Dy8JzWdfISTLFrDk014pN"}
URI: https://terminus.pantheon.io:443/api/sites/f1dfea7b-8490-435f-823e-d8d4efdcee57?site_state=true
Method: GET
Body:
[debug] #### RESPONSE ####
Headers: {headers}
Data: {data}
Status Code: 200
[debug] #### REQUEST ####
Headers: {"User-Agent":"Terminus\/1.0.0 (php_version=5.6.30&script=bin\/terminus)","Content-type":"application\/json","Authorization":"Bearer 451758e4-d187-4ead-a7ea-a9077b3557d5:b894f536-188f-11e7-bcd8-bc764e1022a9:Dy8JzWdfISTLFrDk014pN"}
URI: https://terminus.pantheon.io:443/api/sites/f1dfea7b-8490-435f-823e-d8d4efdcee57/environments
Method: GET
Body:
[debug] #### RESPONSE ####
Headers: {headers}
Data: {data}
Status Code: 200
[warning] This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.
[notice] Command: craft-council.sprint -- 'drush updb --yes' [Exit: 0]
[notice] A new Terminus version v1.1.1 is available.
You are currently using version v1.0.0.
You can update Terminus by running `composer update` or using the Terminus installer:
curl -O https://raw.githubusercontent.com/pantheon-systems/terminus-installer/master/builds/installer.phar && php installer.phar install

Steps to reproduce the behavior

This is the same ran from inside aquifer or via commandline.

----------- ------------------------------------------
PHP         /usr/local/Cellar/php56/5.6.30_6/bin/php
  binary
  PHP         5.6.30
  version
  php.ini     /usr/local/etc/php/5.6/php.ini
  used
  Terminus
  project
  config
  Terminus    /usr/local/Cellar/terminus/1.1.1
  root dir
  Terminus    1.1.1
version
  Operating   Darwin Kernel Version 16.4.0: Thu Dec 22
  system      22:53:21 PST 2016;
              root:xnu-3789.41.3~3/RELEASE_X86_64
 ----------- ------------------------------------------

Other notes... the commands in aquifer.json can be naked and not wrapped in bash -c, but I wanted to make sure that it wasn't some funky parsing logic in aquifer.

greg-1-anderson commented 7 years ago

Maybe this has something to do with I/O redirection; this is something that changed post-1.0.0.

Does it work better to run the commands non-interactively, e.g.:

terminus -n drush craft-council.sprint -- updb --yes

generalredneck commented 7 years ago

No change in fact.

greg-1-anderson commented 7 years ago

Try again with -n on the latest dev version of Terminus. Potentially fixed by https://github.com/pantheon-systems/terminus/pull/1700

generalredneck commented 7 years ago

doesn't appear to be the case... it gets suck right before displaying [notice] Command: craft-council.live -- drush cr [Exit: 0]

greg-1-anderson commented 7 years ago

What version of Terminus are you using? There have been some changes / improvements in I/O handling recently. Try 1.4.0 or master if you are on something earlier.

generalredneck commented 7 years ago

1.4.0 Sorry bout not supplying that earlier.

generalredneck commented 7 years ago

This script will reproduce it

const spawn = require('child_process').spawn;
const parseArgs = require('parse-spawn-args').parse;
var cmd = 'terminus drush -n craft-council.sprint -- cr';
var options = {};
var command_parse = function(command) {
    return {
      name: command.substr(0, command.indexOf(' ')),
      args: parseArgs(command.substr(command.indexOf(' ') + 1))
    }
};
var command = command_parse(cmd);
let child = spawn(command.name, command.args, options);
child.stdout.on('data', (data) => {
  console.log(data.toString('utf8').trim());
});

child.stderr.on('data', (data) => {
  console.log(data.toString('utf8').trim());
});

child.on('close', (code) => {
  if (code !== 0) {
    return reject(command.name + 'command exited with code ' + code);
  }
  resolve();
});

Save this as test.js and run node test.js. Be sure to change the site name and environment to something you can use. I am currently testing with node v7.2.1

mattbailey37 commented 7 years ago

@generalredneck just want to chime in and say I've run into this (see #1699 and #1700). @greg-1-anderson made some fixes for the tty/interactive part, but that didn't have the desired effect. We had to disable some of the Terminus usage via node in the meanwhile. I finally had some cycles to take another look.

Here's an interesting datapoint I discovered: if you use execSync instead of exec, it actually works:

const childProcess = require('child_process');

const exec = (command) => {
   const myProcess = childProcess.execSync(command);
   process.stdout.write(myProcess);
}

exec('terminus -n drush mysite.myenv -- cc all -y');

If you run the bare command outside of the node script, it works fine and displays the [notice] Command: mysite.myenv -- drush cc all [Exit: 0]. This makes me believe the issue is in the interaction between node child processes handling output from the Terminus operations.

Update: The process appears to hang here: https://github.com/pantheon-systems/terminus/blob/master/src/Helpers/LocalMachineHelper.php#L63 It gets past start() and never gets past wait($callback). $callback should be this function: https://github.com/pantheon-systems/terminus/blob/master/src/Commands/Remote/SSHBaseCommand.php#L65

generalredneck commented 6 years ago

Ok as of 1.6.1 this appears to be fixed.

generalredneck commented 6 years ago

Well crap... jumped the gun... still gets hung up at the end of the script complete.

JulienMelissas commented 3 years ago

We have been experiencing this not in node, but in a CI that we use to run commands. Any wp -- command (such as terminus wp site.test -- site list) will just hang in that environment and never exit. We are using Buddy.works.

We're using the latest version of Terminus, but this also never worked for us on v1.9+, which we used to use in our CI.

Would love to see this solved... we are only able to do terminus wp -- commands with a timeout around it, or by exiting another way.

greg-1-anderson commented 3 years ago

Does your CI environment that is running Terminus have the Posix extension?

JulienMelissas commented 3 years ago

@greg-1-anderson - thanks for the reply. We're also working with our Pantheon CSM, Amber on this. Yep, we tested based on your post on another issue, see screenshot here:

CleanShot 2021-07-28 at 17 38 55@2x
gabesullice commented 2 years ago

Resurrecting this issue.

I'm trying to execute terminus from a node.js script as well. In my case, I'm trying to set up a browser test by running a remote:drush command against my multi-dev environment. My code is nearly identical to @generalredneck's. I've confirmed that I have the POSIX extension as well:

circleci@ff372b26eba7:~$ echo $(php -r 'var_export(function_exists("posix_isatty"));')
true
circleci@ff372b26eba7:~$ terminus -v
Terminus 3.0.4

Can I help by providing any other debugging information?