~schnouki/watch_tabnine

bfb802b402726853119fc89b854c5f6f2b1452c5 — Thomas Jost 5 years ago 4076911
Add systemd service and Makefile install target
4 files changed, 38 insertions(+), 3 deletions(-)

M .gitignore
M Makefile
M README.md
A watch_tabnine.service.in
M .gitignore => .gitignore +1 -0
@@ 1,2 1,3 @@
watch_tabnine
watch_tabnine.service
*.o

M Makefile => Makefile +19 -3
@@ 1,15 1,31 @@
all: watch_tabnine
TARGETS = watch_tabnine watch_tabnine.service

all: $(TARGETS)

DC ?= dmd
DC_CFLAGS ?= -O
DC_LDFLAGS ?= -O

destdir ?=
PREFIX ?= /usr/local

watch_tabnine: watch_tabnine.o
	$(DC) $(DC_LDFLAGS) -of=$@ $^

%.o: %.d
	$(DC) -c $(DC_CFLAGS) -of=$@ $<

.PHONY: clean
watch_tabnine.service: watch_tabnine.service.in
	cat $< | sed \
	    's#__destdir__#$(destdir)#g; s#__PREFIX__#$(PREFIX)#g' \
	    > $@

.PHONY: clean install install-bin install-service
clean:
	rm -f watch_tabnine *.o
	rm -f $(TARGETS) *.o

install: install-bin install-service
install-bin: watch_tabnine
	install -D -m755 watch_tabnine $(destdir)$(PREFIX)/bin/watch_tabnine
install-service: watch_tabnine.service
	install -D -m644 watch_tabnine.service $(destdir)$(PREFIX)/lib/systemd/system/watch_tabnine.service

M README.md => README.md +9 -0
@@ 29,6 29,15 @@ At the moment there is no pre-built binary: you need to compile this yourself.

        ./watch_tabnine

5. Optional: install it

        sudo make install PREFIX=/usr/local

6. Optional: after installing it, run it through systemd:

        sudo sytemctl daemon-reload
        sudo systemctl enable --now watch_tabnine


## Usage


A watch_tabnine.service.in => watch_tabnine.service.in +9 -0
@@ 0,0 1,9 @@
[Unit]
Description=Watch TabNine

[Service]
ExecStart=__destdir____PREFIX__/bin/watch_tabnine
Restart=on-failure

[Install]
WantedBy=default.target