-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathunstable
executable file
·71 lines (55 loc) · 1.58 KB
/
unstable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
import argparse
import os
from pathlib import Path
from subprocess import check_call
this = Path(__file__).absolute()
site_bin = Path('/L/soft/beepb00p/site')
def beepb00p(*args):
check_call([
str(site_bin),
*args,
], cwd=this.parent)
# run beepb00p watch --no-server (how to make sure it's not buffering output?)
# if 'Cache corrupt' in output, warn somehow (e.g. ntfy to start with?)
# every night, just restart and rebuild?
# TODO move atomically once built?
# TODO last update?
# shit...
# Removing _site...
# beepb00p: _site: removeDirectoryRecursive: inappropriate type (not a directory)
def systemd(args):
from kython.ksystemd import setup
unit = 'beepb00p.service'
setup(
unit_name=unit,
exec_start=f'{this} run',
)
# TODO exec jcu -f --unit beepb00p.service
def install(args):
check_call([
'stack', 'install',
'--local-bin-path',
str(site_bin.parent),
], cwd=this.parent)
def run(args):
beepb00p('clean')
check_call([
str(this.parent / 'watch'),
'--no-server',
], env={'SITE_COMMAND': str(site_bin), **os.environ})
# TODO maybe restart via systemd instead?
def main():
p = argparse.ArgumentParser()
sp = p.add_subparsers(dest='mode')
sdp = sp.add_parser('systemd')
sdp.set_defaults(func=systemd)
ip = sp.add_parser('install')
ip.set_defaults(func=install)
runp = sp.add_parser('run')
runp.set_defaults(func=run)
args = p.parse_args()
args.func(args)
# TODO use asyncio?
if __name__ == '__main__':
main()