Merge ~mthaddon/ubuntu-mirror-charm/+git/ubuntu-mirror-charm:sendfile into ubuntu-mirror-charm:master

Proposed by Tom Haddon
Status: Merged
Approved by: Junien F
Approved revision: 026f6b9ad4b49b89ac236a38404a77c0464c26cd
Merged at revision: 956a973cf19e95d0d1f5e68e353c40a151a56a4f
Proposed branch: ~mthaddon/ubuntu-mirror-charm/+git/ubuntu-mirror-charm:sendfile
Merge into: ubuntu-mirror-charm:master
Diff against target: 38 lines (+13/-1)
2 files modified
files/sendfile.conf (+2/-0)
hooks/hooks.py (+11/-1)
Reviewer Review Type Date Requested Status
Junien F Approve
Canonical IS Reviewers Pending
Review via email: mp+447086@code.launchpad.net

Commit message

Add sendfile support

Description of the change

Add sendfile support

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Junien F (axino) wrote :

+1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 956a973cf19e95d0d1f5e68e353c40a151a56a4f

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/files/sendfile.conf b/files/sendfile.conf
2new file mode 100644
3index 0000000..b67075f
4--- /dev/null
5+++ b/files/sendfile.conf
6@@ -0,0 +1,2 @@
7+# File managed by Juju.
8+EnableSendfile on
9diff --git a/hooks/hooks.py b/hooks/hooks.py
10index afabcbe..e39276b 100755
11--- a/hooks/hooks.py
12+++ b/hooks/hooks.py
13@@ -592,6 +592,16 @@ def configure_apache(conf, hostname): # noqa: C901
14 check_call(['/usr/sbin/a2enmod', 'ssl'])
15 restart_for_ssl = True
16
17+ # Enable sendfile
18+ restart_for_sendfile = False
19+ sendfile_dest = os.path.join(apache_dir, "conf-available", "juju-sendfile.conf")
20+ sendfile_src = os.path.join(charm_dir(), "files", "sendfile.conf")
21+ if not os.path.exists(sendfile_dest) or (open(sendfile_dest, 'r').read() != open(sendfile_src, 'r').read()):
22+ shutil.copyfile(sendfile_src, sendfile_dest)
23+ os.chmod(sendfile_dest, 0o644)
24+ check_call(["/usr/sbin/a2enconf", "juju-sendfile"])
25+ restart_for_sendfile = True
26+
27 # Remove all other vhosts
28 unwanted_vhosts = set(conf.role_list()) - set(wanted_vhosts)
29 # always disable default
30@@ -636,7 +646,7 @@ def configure_apache(conf, hostname): # noqa: C901
31 override_file = '{}/override.conf'.format(systemd_apachedir)
32 file_from_template("systemd-apache-override.tmpl", override_file, tmpl_data)
33
34- if restart_for_mpm or restart_for_ssl:
35+ if restart_for_mpm or restart_for_ssl or restart_for_sendfile:
36 log("CHARM: Restarting apache")
37 check_call('systemctl daemon-reload'.split())
38 service_restart("apache2")

Subscribers

People subscribed via source and target branches