jenkins-bot has submitted this change and it was merged.
Change subject: Make debugging CLI scripts via XDebug easier
......................................................................
Make debugging CLI scripts via XDebug easier
Adds xdebug_on and xdebug_off shell commands which enable/disable
XDebug to connect to the host machine whenever a script is run
via CLI.
The host IP is derived from the static host-only IP address of the VM
and set as a custom fact in the Vagrantfile.
CLI debugging does not seem to work at all with HHVM.
Bug: T59676
Change-Id: Icf7fbb9b1aab48667d765fdb0ffd92128bf5ef32
---
M Vagrantfile
M puppet/modules/misc/manifests/init.pp
A puppet/modules/misc/templates/xdebug.erb
3 files changed, 24 insertions(+), 0 deletions(-)
Approvals:
Dduvall: Looks good to me, approved
Gergő Tisza: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/Vagrantfile b/Vagrantfile
index a12d088..218872a 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -31,6 +31,7 @@
# Ensure we're using the latest version of the plugin
require_relative 'lib/mediawiki-vagrant/version'
require 'fileutils'
+require 'ipaddr'
# NOTE Use RubyGems over the Vagrant plugin manager as it's more reliable
gemspec = Gem::Specification.find { |s| s.name == 'mediawiki-vagrant' }
@@ -196,6 +197,12 @@
$FACTER['share_group'] = 'www-data'
end
+ # Derive a host IP from the configured static IP by getting the first
+ # usable IP in the 8-bit network
+ if settings[:static_ip]
+ network = IPAddr.new("#{settings[:static_ip]}/24")
+ $FACTER['host_ip'] = network.to_range.take(2).last.to_s
+ end
end
if Vagrant.plugin('2').manager.provisioners[:mediawiki_reload] && \
diff --git a/puppet/modules/misc/manifests/init.pp
b/puppet/modules/misc/manifests/init.pp
index 9358a31..4de0fcc 100644
--- a/puppet/modules/misc/manifests/init.pp
+++ b/puppet/modules/misc/manifests/init.pp
@@ -37,4 +37,8 @@
command => 'sed -i -e "s/^mesg n/tty -s \&\& mesg n/" /root/.profile',
onlyif => 'grep -q "^mesg n" /root/.profile',
}
+
+ env::profile_script { 'xdebug':
+ content => template('misc/xdebug.erb'),
+ }
}
diff --git a/puppet/modules/misc/templates/xdebug.erb
b/puppet/modules/misc/templates/xdebug.erb
new file mode 100644
index 0000000..c76e7e4
--- /dev/null
+++ b/puppet/modules/misc/templates/xdebug.erb
@@ -0,0 +1,13 @@
+# Enable/disable Xdebug for PHP CLI scripts.
+# This file is managed by Puppet.
+
+xdebug_on() {
+ # http://xdebug.org/docs/remote#starting
+ export XDEBUG_CONFIG='idekey=xdebug remote_host=<%= scope['host_ip'] %>'
+ #
http://blog.jetbrains.com/webide/2012/03/new-in-4-0-easier-debugging-of-remote-php-command-line-scripts/
+ export PHP_IDE_CONFIG='serverName=<%= scope['::role::mediawiki::hostname']
%>'
+}
+xdebug_off() {
+ unset XDEBUG_CONFIG
+ unset PHP_IDE_CONFIG
+}
--
To view, visit https://gerrit.wikimedia.org/r/187836
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf7fbb9b1aab48667d765fdb0ffd92128bf5ef32
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits