Created
October 6, 2017 14:18
-
-
Save omaraboumrad/7fb7c60038591ee65961b85e7f8d2096 to your computer and use it in GitHub Desktop.
View docker-compose services logs in split tmux panes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires pyyaml | |
import os | |
import yaml | |
run = os.system | |
new_window = lambda cmd: run('tmux new-window -n "logs" "{}"'.format(cmd)) | |
split_vertical = lambda cmd: run('tmux split-window "{}"'.format(cmd)) | |
split_horizontal = lambda cmd: run('tmux split-window -h "{}"'.format(cmd)) | |
even_vertical = lambda: run('tmux select-layout even-vertical') | |
if __name__ == '__main__': | |
try: | |
config_text = open('docker-compose.yaml').read() | |
except IOError: | |
config_text = open('docker-compose.yml').read() | |
config = yaml.load(config_text) | |
services = config['services'].keys() | |
new_window('docker-compose logs -f {}'.format(services[0])) | |
for service in services[1:]: | |
split_horizontal('docker-compose logs -f {}'.format(service)) | |
even_vertical() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get around this warning:
...you need to change line 18 to: