Skip to content

Commit dbd1d1e

Browse files
committed
QAG-65: (fix) Fix Elasticsearch plugin installation and restart mechanism
- Changed marker file location from container-only /tmp to shared mounted directory - Replaced "ddev restart elasticsearch" with direct docker container restart Refs: .ddev/elasticsearch/elasticsearch-setup.sh, .ddev/config.yaml
1 parent 6c3581c commit dbd1d1e

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

.ddev/config.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ hooks:
3333
post-start:
3434
- exec: "composer install"
3535
- exec: "npm ci"
36-
- exec-host: "ddev exec -s elasticsearch /mnt/ddev_config/elasticsearch/elasticsearch-setup.sh"
3736
- exec-host: |
38-
if [ -f /tmp/elasticsearch_needs_restart ]; then
39-
echo "Restarting Elasticsearch to apply plugin changes..."
40-
ddev restart elasticsearch
41-
rm /tmp/elasticsearch_needs_restart
37+
# Run the Elasticsearch plugin setup script
38+
ddev exec -s elasticsearch /mnt/ddev_config/elasticsearch/elasticsearch-setup.sh
39+
40+
# Check for the restart marker file
41+
if [ -f .ddev/elasticsearch/restart_needed ]; then
42+
echo "Elasticsearch plugins installed. Restarting elasticsearch container..."
43+
docker restart ddev-${DDEV_SITENAME}-elasticsearch
44+
rm .ddev/elasticsearch/restart_needed
4245
fi

.ddev/elasticsearch/elasticsearch-setup.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@ for plugin in $ELASTICSEARCH_PLUGINS; do
1616

1717
# Install plugin
1818
echo "Installing $plugin plugin..."
19-
bin/elasticsearch-plugin install "$plugin" && \
20-
chown -R elasticsearch:root "/usr/share/elasticsearch/plugins/$plugin" && \
21-
chmod -R 755 "/usr/share/elasticsearch/plugins/$plugin" && \
22-
echo "✓ Plugin $plugin installed successfully" && \
23-
needs_restart=true
19+
if bin/elasticsearch-plugin install "$plugin"; then
20+
chown -R elasticsearch:root "/usr/share/elasticsearch/plugins/$plugin" && \
21+
chmod -R 755 "/usr/share/elasticsearch/plugins/$plugin" && \
22+
echo "✓ Plugin $plugin installed successfully" && \
23+
needs_restart=true
24+
else
25+
echo "✗ Failed to install plugin $plugin"
26+
exit 1
27+
fi
2428
done
2529

2630
# Signal for restart if needed
27-
[ "$needs_restart" = true ] && echo "New plugins were installed. Elasticsearch needs to be restarted." && touch /tmp/elasticsearch_needs_restart
31+
if [ "$needs_restart" = true ]; then
32+
echo "New plugins were installed. Elasticsearch needs to be restarted."
33+
34+
# Create a marker file in the mounted config directory (visible to host)
35+
touch /mnt/ddev_config/elasticsearch/restart_needed
36+
fi
2837

2938
exit 0

0 commit comments

Comments
 (0)