This repository was archived by the owner on Dec 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ SETTINGS_FILE = "local.yml"
1818# load the settingsfile or if it does not exist yet a hash where every attribute two levels deep is nil
1919settings = YAML . load_file ( SETTINGS_FILE ) rescue Hash . new ( Hash . new ( nil ) )
2020
21+ require_relative 'vagrant/plugins/inline/ensure-varnish.rb'
2122Vagrant . configure ( VAGRANTFILE_API_VERSION ) do |config |
2223 # run hypernode-vagrant configuration wizard if needed during 'vagrant up'
2324 config . hypconfigmgmt . enabled = true
Original file line number Diff line number Diff line change 1+ require "vagrant"
2+
3+ module VagrantPlugins
4+ module VagrantInlinePlugin
5+ class Command
6+ def initialize ( app , env )
7+ @app = app
8+ @env = env
9+ end
10+
11+ def call ( env )
12+ env [ :machine ] . communicate . sudo (
13+ "ps -ef | grep -v \" grep\" | grep varnishd -q || (service varnish start && sleep 1)" ,
14+ { :error_check => false }
15+ ) do |type , data |
16+ output = data . to_s . strip ( )
17+ if output . include? "Starting HTTP accelerator varnishd"
18+ env [ :ui ] . info ( "Started Varnish" )
19+ end
20+ end
21+ @app . call ( env )
22+ end
23+ end
24+ end
25+
26+ class Plugin < Vagrant . plugin ( "2" )
27+ name "Ensure varnish is started as soon as the instance is started"
28+
29+ action_hook ( :VagrantInlinePlugin ) do |hook |
30+ hook . after (
31+ Vagrant ::Action ::Builtin ::WaitForCommunicator ,
32+ VagrantInlinePlugin ::Command
33+ )
34+ end
35+ end
36+ end
Original file line number Diff line number Diff line change 4343
4444# Restart varnish if the hostname changed
4545if [ ! -d " /var/lib/varnish/$HOSTNAME " ]; then
46- service varnish restart
46+ service varnish restart && sleep 1
4747fi
4848
4949rm -rf /etc/cron.d/hypernode-fpm-monitor
6565 sudo -u $user rm -f /data/web/nginx/magento2.flag
6666fi
6767
68- # ensure varnish is running. in lxc vagrant boxes for some reason the varnish init script in /etc/init.d doesn't bring up the service on boot
69- # todo: find out why varnish isn't always started on startup on lxc instances
70- ps -ef | grep -v " grep" | grep varnishd -q || (service varnish start && sleep 1)
71-
7268# if the webroot is empty, place our default index.php which shows the settings
7369if ! find /data/web/public/ -mindepth 1 -name ' *.php' -name ' *.html' | read ; then
7470 cp /vagrant/vagrant/resources/* .{php,js,css} /data/web/public/
@@ -132,7 +128,7 @@ if $xdebug_enabled; then
132128 echo " this article: https://support.hypernode.com/knowledgebase/install-xdebug-hypernode-vagrant/"
133129fi
134130
135- if ! $varnish_enabled ; then
131+ if ! $varnish_enabled ; then
136132 su $user -c " echo -e 'vcl 4.0;\nbackend default {\n .host = \" 127.0.0.1\" ;\n .port= \" 8080\" ;\n}\nsub vcl_recv {\n return(pass);\n}' > /data/web/disabled_caching.vcl"
137133 varnishadm vcl.list | grep -q nocache || varnishadm vcl.load nocache /data/web/disabled_caching.vcl
138134 varnishadm vcl.use nocache
You can’t perform that action at this time.
0 commit comments