├── rotate-to-s3.json ├── NOTICE ├── Makefile.deb ├── rotate-to-s3 ├── README.md ├── rotate-to-s3.py └── LICENSE /rotate-to-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "destination": "myBucket", 3 | "access": "ABCDEFGHIJKLMNOPQRSTU", 4 | "secret": "SUMthefiveboxingwizardsjumpedquickly", 5 | "source": [ 6 | { 7 | "directory": "/var/log/nginx", 8 | "files": [ 9 | "access.log", 10 | "error.log" 11 | ] 12 | } 13 | ], 14 | "pidfile": "/var/run/nginx.pid" 15 | } 16 | 17 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Corsis 2 | http://www.corsis.com/ 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /Makefile.deb: -------------------------------------------------------------------------------- 1 | NAME=rotate-to-s3 2 | VERSION=1.0 3 | MAINT="Anthony Tonns " 4 | VENDOR="Corsis" 5 | URL="https://github.com/dialt0ne/rotate-to-s3" 6 | DESCR="Script to rotate webserver log file to AWS S3" 7 | LICENSE="Apache2.0" 8 | 9 | .PHONY: package 10 | package: $(NAME)_$(VERSION)_all.deb 11 | $(NAME)_$(VERSION)_all.deb: rotate-to-s3.py rotate-to-s3.json rotate-to-s3 12 | rm -rf p 13 | mkdir p 14 | mkdir p/opt 15 | mkdir p/opt/corsis 16 | mkdir p/opt/corsis/bin 17 | mkdir p/opt/corsis/etc 18 | cp -p rotate-to-s3.py p/opt/corsis/bin/ 19 | cp -p rotate-to-s3.json p/opt/corsis/etc/ 20 | mkdir p/etc 21 | mkdir p/etc/init.d 22 | cp -p rotate-to-s3 p/etc/init.d/ 23 | fpm -s dir -t deb -C p -a all \ 24 | -m $(MAINT) --vendor $(VENDOR) --description $(DESCR) \ 25 | --url $(URL) -n $(NAME) -v $(VERSION) --license $(LICENSE) \ 26 | opt etc 27 | rm -rf p 28 | 29 | clean: 30 | rm -rf $(NAME)_$(VERSION)_all.deb 31 | -------------------------------------------------------------------------------- /rotate-to-s3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # rotate-to-s3 move logs to s3 at shutdown 4 | # 5 | # chkconfig: - 01 01 6 | # description: move logs to s3 at shutdown 7 | # 8 | # Provides: rotate-to-s3 9 | # X-Stop-After: $nginx 10 | # Default-Stop: 0 1 6 11 | # Short-Description: rotate-to-s3 12 | # Description: Calls python script to rotate logs to AWS S3 13 | # 14 | # Copyright 2012 Corsis 15 | # http://www.corsis.com/ 16 | # 17 | # Licensed under the Apache License, Version 2.0 (the "License"); 18 | # you may not use this file except in compliance with the License. 19 | # You may obtain a copy of the License at 20 | # 21 | # http://www.apache.org/licenses/LICENSE-2.0 22 | # 23 | # Unless required by applicable law or agreed to in writing, software 24 | # distributed under the License is distributed on an "AS IS" BASIS, 25 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | # See the License for the specific language governing permissions and 27 | # limitations under the License. 28 | # 29 | /opt/corsis/bin/rotate-to-s3.py 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=dialt0ne&url=https://github.com/dialt0ne/rotate-to-s3&title=rotate-to-s3&language=python&tags=github&category=software) 2 | 3 | ## rotate-to-s3.py 4 | 5 | rotate-to-s3.py does the following to rotate your webserver logs from your 6 | Amazon Web Service Elastic Compute Cloud (AWS EC2) instance directly to 7 | an Amazon Web Service Simple Storage Service (AWS S3) bucket: 8 | 9 | * reads the JSON configuration file 10 | * renames active logfiles 11 | * signals the webserver to logswitch 12 | * compresses old logfiles 13 | * uploads compessed logfiles to an S3 bucket 14 | 15 | So, if the logfile is named `access.log` it will be rotated to S3 with 16 | the name `90abcdef-YYYYMMDD-HHMMSS-access.log.gz` where `90abcdef` is the 17 | EC2 instance ID of the system, without the leading `i-` (see this 18 | [blog post](http://aws.typepad.com/aws/2012/03/amazon-s3-performance-tips-tricks-seattle-hiring-event.html) why). 19 | 20 | If the init script is installed, it will also move the logs to S3 on 21 | shutdown or reboot so that no logs are lost at instance termination. 22 | 23 | ### How to install 24 | 25 | #### Ubuntu system 26 | 27 | git clone git://github.com/dialt0ne/rotate-to-s3.git 28 | which fpm || echo "ERROR: requires fpm" 29 | make -f Makefile.deb 30 | sudo dpkg -i rotate-to-s3_1.0_all.deb 31 | sudo update-rc.d rotate-to-s3 defaults 32 | 33 | #### Chef 34 | 35 | See: https://github.com/dialt0ne/cookbook-rotate-to-s3 36 | 37 | ### Configuration 38 | 39 | cd /opt/corsis/etc 40 | sudo $EDITOR rotate-to-s3.json 41 | # customize as needed 42 | 43 | sudo crontab -e 44 | #>>> 45 | 0 * * * * /opt/corsis/bin/rotate-to-s3.py -c /opt/corsis/etc/rotate-to-s3.json 46 | 47 | ### Usage 48 | 49 | $ ./rotate-to-s3.py -h 50 | usage: rotate-to-s3.py [-h] [-c CONFIG] 51 | 52 | optional arguments: 53 | -h, --help show this help message and exit 54 | -c CONFIG, --config CONFIG 55 | json config file, default: rotate-to-s3.json 56 | 57 | ### ToDo 58 | 59 | * possibly retry on S3 upload issues 60 | * better error handling and reporting 61 | 62 | ### License 63 | 64 | Copyright 2012 Corsis 65 | http://www.corsis.com/ 66 | 67 | Licensed under the Apache License, Version 2.0 (the "License"); 68 | you may not use this file except in compliance with the License. 69 | You may obtain a copy of the License at 70 | 71 | http://www.apache.org/licenses/LICENSE-2.0 72 | 73 | Unless required by applicable law or agreed to in writing, software 74 | distributed under the License is distributed on an "AS IS" BASIS, 75 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 76 | See the License for the specific language governing permissions and 77 | limitations under the License. 78 | 79 | -------------------------------------------------------------------------------- /rotate-to-s3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # rotate-to-s3.py 4 | # 5 | # ATonns Wed Mar 14 19:40:57 UTC 2012 6 | # 7 | # Copyright 2012 Corsis 8 | # http://www.corsis.com/ 9 | # 10 | # Licensed under the Apache License, Version 2.0 (the "License"); 11 | # you may not use this file except in compliance with the License. 12 | # You may obtain a copy of the License at 13 | # 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | # 16 | # Unless required by applicable law or agreed to in writing, software 17 | # distributed under the License is distributed on an "AS IS" BASIS, 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | # See the License for the specific language governing permissions and 20 | # limitations under the License. 21 | 22 | import argparse 23 | import boto 24 | import gzip 25 | import httplib2 26 | import json 27 | import logging 28 | import os 29 | import re 30 | import signal 31 | import sys 32 | import time 33 | 34 | defaultConfigFile = "/opt/corsis/etc/rotate-to-s3.json" 35 | 36 | 37 | def getInstanceId(): 38 | h = httplib2.Http() 39 | # get the instance id from the aws meta data 40 | url = "http://169.254.169.254/latest/meta-data/instance-id" 41 | resp, content = h.request(url, "GET") 42 | # strip out the leading 'i-' 43 | match = re.search('i-(.+)', content) 44 | iid = match.group(1) 45 | return iid 46 | 47 | 48 | def getConf(filename): 49 | with open(filename, 'r') as f: 50 | config = f.read() 51 | c = json.loads(config) 52 | return c 53 | 54 | 55 | def getPid(pidfile): 56 | with open(pidfile, 'r') as p: 57 | # remove all trailing whitespace, especially the newline 58 | pid = p.readline().rstrip() 59 | return int(pid) 60 | 61 | 62 | def compressFile(src, dest): 63 | with open(src, 'rb') as f_src: 64 | with gzip.open(dest, 'wb') as f_dest: 65 | f_dest.writelines(f_src) 66 | 67 | 68 | def testS3(access, secret, bucket, iid, now): 69 | c = boto.connect_s3(access, secret) 70 | b = c.create_bucket(bucket) 71 | k = boto.s3.key.Key(b) 72 | # only a test key 73 | test_key = iid + "-" + now + "-test" 74 | k.key = test_key 75 | # with test data 76 | k.set_contents_from_string('Testing S3 at ' + now) 77 | k.delete() 78 | 79 | 80 | def uploadtoS3(access, secret, bucket, sourcefile, destinationfile): 81 | c = boto.connect_s3(access, secret) 82 | b = c.create_bucket(bucket) 83 | k = boto.s3.key.Key(b) 84 | k.key = destinationfile 85 | k.set_contents_from_filename(sourcefile) 86 | 87 | 88 | if __name__ == '__main__': 89 | logging.basicConfig(format="rotate-to-s3.py: %(message)s") 90 | now = time.strftime('%Y%m%d-%H%M%S') 91 | parser = argparse.ArgumentParser(prog='rotate-to-s3.py') 92 | parser.add_argument("-c", "--config", dest="config", 93 | default=defaultConfigFile, 94 | help="json config file, default: " + defaultConfigFile) 95 | args = parser.parse_args() 96 | try: 97 | conf = getConf(args.config) 98 | except IOError as (errno, strerror): 99 | logging.error("Error opening config file %s: %s, quitting", 100 | args.config, strerror) 101 | sys.exit(1) 102 | try: 103 | pid = getPid(conf[u'pidfile']) 104 | except IOError as (errno, strerror): 105 | logging.error("Error opening pid file %s: %s, quitting", 106 | conf[u'pidfile'], strerror) 107 | sys.exit(1) 108 | try: 109 | instanceId = getInstanceId() 110 | except: 111 | logging.error("Error getting EC2 instance id, quitting") 112 | sys.exit(1) 113 | # try connecting to S3 before we even start 114 | bucket = conf[u'destination'] 115 | aws_access_key = conf[u'access'] 116 | aws_secret_access_key = conf[u'secret'] 117 | try: 118 | testS3(aws_access_key, aws_secret_access_key, 119 | bucket, instanceId, now) 120 | except boto.exception.NoAuthHandlerFound: 121 | logging.error("S3 authentication error, quitting") 122 | sys.exit(2) 123 | except boto.exception.S3CreateError as (status, reason): 124 | logging.error("S3 Error creating %s:%s: %s, quitting", 125 | bucket, now + 'test', reason) 126 | sys.exit(2) 127 | except boto.exception.S3PermissionsError as (reason): 128 | logging.error("S3 Error with permissions on %s:%s: %s, quitting", 129 | bucket, instanceId + "-" + now + "-test", reason) 130 | sys.exit(2) 131 | except: 132 | logging.error("S3 unknown error, quitting") 133 | sys.exit(2) 134 | # rename files prior to rotate 135 | for src in conf[u'source']: 136 | logdir = src[u'directory'] 137 | for filename in src[u'files']: 138 | oldName = logdir + "/" + filename 139 | oldSize = 0 140 | if os.path.isfile(oldName) is True: 141 | oldSize = os.stat(oldName).st_size 142 | # don't bother with zero-length logfiles 143 | if oldSize == 0: 144 | break 145 | newName = logdir + "/" + now + '-' + filename 146 | # rotate the logs 147 | try: 148 | os.rename(oldName, newName) 149 | except OSError as (errno, strerror): 150 | logging.error("Error renaming %s to %s: %s", 151 | oldName, newName, strerror) 152 | # force process to logswitch 153 | os.kill(pid, signal.SIGUSR1) 154 | # wait for it to complete 155 | time.sleep(1) 156 | # compress logs 157 | for src in conf[u'source']: 158 | logdir = src[u'directory'] 159 | for filename in src[u'files']: 160 | newName = logdir + "/" + now + '-' + filename 161 | if os.path.isfile(newName) is False: 162 | break 163 | zipName = logdir + "/" + now + '-' + filename + '.gz' 164 | # gzip the file 165 | try: 166 | compressFile(newName, zipName) 167 | os.remove(newName) 168 | except IOError as (errno, strerror): 169 | logging.error("Error zipping %s to %s: %s", 170 | newName, zipName, strerror) 171 | except OSError as (errno, strerror): 172 | logging.error("Error removing after zip %s: %s", 173 | newName, strerror) 174 | # upload logs 175 | for src in conf[u'source']: 176 | logdir = src[u'directory'] 177 | for filename in src[u'files']: 178 | zipName = logdir + "/" + now + '-' + filename + '.gz' 179 | if os.path.isfile(zipName) is False: 180 | break 181 | s3Name = instanceId + '-' + now + '-' + filename + '.gz' 182 | # push to s3 183 | try: 184 | uploadtoS3(aws_access_key, aws_secret_access_key, 185 | bucket, zipName, s3Name) 186 | os.remove(zipName) 187 | except IOError as (errno, strerror): 188 | logging.error("Error uploading %s to %s:%s: %s", 189 | zipName, bucket, s3Name, strerror) 190 | except OSError as (errno, strerror): 191 | logging.error("Error removing after upload %s: %s", 192 | zipName, strerror) 193 | except boto.exception.S3CreateError as (status, reason): 194 | logging.error("S3 Error creating %s:%s: %s", 195 | bucket, s3Name, reason) 196 | except boto.exception.S3PermissionsError as (reason): 197 | logging.error("S3 Error with permissions on %s:%s: %s", 198 | bucket, s3Name, reason) 199 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------