Open generalredneck opened 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
No change in fact.
Try again with -n
on the latest dev version of Terminus. Potentially fixed by https://github.com/pantheon-systems/terminus/pull/1700
doesn't appear to be the case... it gets suck right before displaying [notice] Command: craft-council.live -- drush cr [Exit: 0]
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.
1.4.0 Sorry bout not supplying that earlier.
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
@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
Ok as of 1.6.1 this appears to be fixed.
Well crap... jumped the gun... still gets hung up at the end of the script complete.
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.
Does your CI environment that is running Terminus have the Posix extension?
@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:
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?
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
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 theterminus drush
commands just hang without doing anything (exterminus -vvv drush craft-council.sprint -- updb --yes
)In fact here is the output of that command using 1.1.1
Here is the output of the same command run on commandline (not from aquifer)
A quick diff of the 2 shows this:
Just in case you are curious... this is what the commands look like ran in terminus 1.0.0
Steps to reproduce the behavior
This is the same ran from inside aquifer or via commandline.
npm install --global aquifer@1.0.0-beta3
aquifer.json
in your directory that looks like:mkdir build
aquifer run sprint
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.