Compare commits
	
		
			No commits in common. "b6cfc84e866d3b3b38fee4c6e1bc8d60df457901" and "0f74cc8c7e30efc2d8c9372504b99384b2c57b19" have entirely different histories.
		
	
	
		
			b6cfc84e86
			...
			0f74cc8c7e
		
	
		
					 5 changed files with 58 additions and 57 deletions
				
			
		
							
								
								
									
										12
									
								
								.envrc
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								.envrc
									
									
									
									
									
								
							| 
						 | 
					@ -13,17 +13,9 @@ PATH_add bin
 | 
				
			||||||
python3 -m pip --require-virtualenv --quiet install --upgrade pip wheel
 | 
					python3 -m pip --require-virtualenv --quiet install --upgrade pip wheel
 | 
				
			||||||
python3 -m pip --require-virtualenv --quiet install --upgrade -r requirements.txt
 | 
					python3 -m pip --require-virtualenv --quiet install --upgrade -r requirements.txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# git deploy cache
 | 
					rm -rf .cache/bw/git_deploy
 | 
				
			||||||
export BW_GIT_DEPLOY_CACHE=".cache/bw/git_deploy"
 | 
					export BW_GIT_DEPLOY_CACHE=.cache/bw/git_deploy
 | 
				
			||||||
CREATED_AT=$(stat -f "%Sa" "$BW_GIT_DEPLOY_CACHE" | xargs -I{} date -f '%b %d %H:%M:%S %Y' -j "{}" '+%s')
 | 
					 | 
				
			||||||
NOW_AT=$(date +%s)
 | 
					 | 
				
			||||||
SECONDS_SINCE=$(expr "$NOW_AT" - "$CREATED_AT")
 | 
					 | 
				
			||||||
if [[ "$SECONDS_SINCE" > 86400 ]]
 | 
					 | 
				
			||||||
then
 | 
					 | 
				
			||||||
  rm -rf "$BW_GIT_DEPLOY_CACHE"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
mkdir -p "$BW_GIT_DEPLOY_CACHE"
 | 
					mkdir -p "$BW_GIT_DEPLOY_CACHE"
 | 
				
			||||||
 | 
					 | 
				
			||||||
export EXPERIMENTAL_UPLOAD_VIA_CAT=1
 | 
					export EXPERIMENTAL_UPLOAD_VIA_CAT=1
 | 
				
			||||||
export BW_ITEM_WORKERS=32
 | 
					export BW_ITEM_WORKERS=32
 | 
				
			||||||
export BW_NODE_WORKERS=12
 | 
					export BW_NODE_WORKERS=12
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,6 @@ from shlex import quote
 | 
				
			||||||
directories['/var/lib/influxdb'] = {
 | 
					directories['/var/lib/influxdb'] = {
 | 
				
			||||||
    'owner': 'influxdb',
 | 
					    'owner': 'influxdb',
 | 
				
			||||||
    'group': 'influxdb',
 | 
					    'group': 'influxdb',
 | 
				
			||||||
    'mode': '0750',
 | 
					 | 
				
			||||||
    'needs': [
 | 
					    'needs': [
 | 
				
			||||||
        'zfs_dataset:tank/influxdb',
 | 
					        'zfs_dataset:tank/influxdb',
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,58 @@
 | 
				
			||||||
svc_systemd = {
 | 
					size = node.metadata.get('systemd-swap')
 | 
				
			||||||
    'swapfile-prepare.service': {
 | 
					
 | 
				
			||||||
        'enabled': True,
 | 
					actions = {
 | 
				
			||||||
        'running': None,
 | 
					    'stop_swap': {
 | 
				
			||||||
 | 
					        'command': f'systemctl stop swapfile.swap',
 | 
				
			||||||
 | 
					        'unless': f'! systemctl is-active swapfile.swap',
 | 
				
			||||||
 | 
					        'triggered': True,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    'swapfile.swap': {
 | 
					    'remove_swapfile': {
 | 
				
			||||||
        'enabled': True,
 | 
					        'command': f'rm /swapfile',
 | 
				
			||||||
        'running': True,
 | 
					        'unless': f'! test -e /swapfile',
 | 
				
			||||||
        'needs': [
 | 
					        'triggered': True,
 | 
				
			||||||
            'svc_systemd:swapfile-prepare.service',
 | 
					        'needs': {
 | 
				
			||||||
        ],
 | 
					            'action:stop_swap',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    'create_swapfile': {
 | 
				
			||||||
 | 
					        'command': f'fallocate -l {size} /swapfile',
 | 
				
			||||||
 | 
					        'unless': f'stat -c %s /swapfile | grep ^{size}$',
 | 
				
			||||||
 | 
					        'preceded_by': {
 | 
				
			||||||
 | 
					            'action:stop_swap',
 | 
				
			||||||
 | 
					            'action:remove_swapfile',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        'triggers': {
 | 
				
			||||||
 | 
					            'action:initialize_swapfile',
 | 
				
			||||||
 | 
					            'svc_systemd:swapfile.swap:restart',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    'swapfile_mode': {
 | 
				
			||||||
 | 
					        'command': f'chmod 600 /swapfile',
 | 
				
			||||||
 | 
					        'unless': f'stat -c "%a" /swapfile | grep -q "^600$"',
 | 
				
			||||||
 | 
					        'needs': {
 | 
				
			||||||
 | 
					            'action:create_swapfile',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        'triggers': {
 | 
				
			||||||
 | 
					            'svc_systemd:swapfile.swap:restart',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    'initialize_swapfile': {
 | 
				
			||||||
 | 
					        'command': f'mkswap /swapfile',
 | 
				
			||||||
 | 
					        'triggered': True,
 | 
				
			||||||
 | 
					        'needs': {
 | 
				
			||||||
 | 
					            'action:swapfile_mode',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					svc_systemd = {
 | 
				
			||||||
 | 
					    'swapfile.swap': {
 | 
				
			||||||
 | 
					        'preceded_by': {
 | 
				
			||||||
 | 
					            'action:initialize_swapfile',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        'needs': {
 | 
				
			||||||
 | 
					            'action:initialize_swapfile',
 | 
				
			||||||
 | 
					            'action:systemd-reload',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,38 +10,3 @@ defaults = {
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@metadata_reactor.provides(
 | 
					 | 
				
			||||||
    'systemd/units/swapfile.swap',
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
def unit(metadata):
 | 
					 | 
				
			||||||
    size = metadata.get('systemd-swap')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return {
 | 
					 | 
				
			||||||
        'systemd': {
 | 
					 | 
				
			||||||
            'units': {
 | 
					 | 
				
			||||||
                'swapfile-prepare.service': {
 | 
					 | 
				
			||||||
                    'Unit': {
 | 
					 | 
				
			||||||
                        'Before': {
 | 
					 | 
				
			||||||
                            'swapfile.swap',
 | 
					 | 
				
			||||||
                        },
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    'Service': {
 | 
					 | 
				
			||||||
                        'Type': 'oneshot',
 | 
					 | 
				
			||||||
                        'ExecStartPre': [
 | 
					 | 
				
			||||||
                            '-/bin/rm /swapfile -f',
 | 
					 | 
				
			||||||
                            f'/bin/fallocate -l {size} /swapfile',
 | 
					 | 
				
			||||||
                            '/bin/chmod 600 /swapfile',
 | 
					 | 
				
			||||||
                        ],
 | 
					 | 
				
			||||||
                        'ExecStart': '/usr/sbin/mkswap /swapfile',
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    'Install': {
 | 
					 | 
				
			||||||
                        'RequiredBy': {
 | 
					 | 
				
			||||||
                            'swapfile.swap',
 | 
					 | 
				
			||||||
                        },
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                },
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ template = '''
 | 
				
			||||||
${option}=${k}=${v}
 | 
					${option}=${k}=${v}
 | 
				
			||||||
%             endfor
 | 
					%             endfor
 | 
				
			||||||
%         elif isinstance(value, (list, set, tuple)):
 | 
					%         elif isinstance(value, (list, set, tuple)):
 | 
				
			||||||
%             for item in (sorted(value) if isinstance(value, set) else value):
 | 
					%             for item in sorted(value):
 | 
				
			||||||
${option}=${item}
 | 
					${option}=${item}
 | 
				
			||||||
%             endfor
 | 
					%             endfor
 | 
				
			||||||
%         elif isinstance(value, type(None)):
 | 
					%         elif isinstance(value, type(None)):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue