Improved build scripts
This commit is contained in:
parent
7286dfb8a2
commit
985423e981
@ -1,4 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
MYDIR="$(dirname "$(readlink -f "$0")")"
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
cd "$MYDIR"
|
cd "$SCRIPTPATH"
|
||||||
for dir in ./*; do ([ -d "$dir" ] && cd "$dir" && echo "Building bots/$dir" && go build); done
|
|
||||||
|
for dir in *; do
|
||||||
|
[ -d "$SCRIPTPATH/$dir" ] &&
|
||||||
|
cd "$SCRIPTPATH/$dir" &&
|
||||||
|
echo "Building bots/$dir" &&
|
||||||
|
go build
|
||||||
|
done
|
@ -1,5 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
MYDIR="$(dirname "$(readlink -f "$0")")"
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
cd "$MYDIR"
|
cd "$SCRIPTPATH"
|
||||||
go build
|
go build
|
||||||
for dir in ./*; do ([ -d "$dir" ] && cd "$dir" && echo "Building jobs/$dir" && go build); done
|
|
||||||
|
for dir in *; do
|
||||||
|
[ -d "$SCRIPTPATH/$dir" ] &&
|
||||||
|
cd "$SCRIPTPATH/$dir" &&
|
||||||
|
echo "Building jobs/$dir" &&
|
||||||
|
go build
|
||||||
|
done
|
63
makefile
63
makefile
@ -4,7 +4,6 @@
|
|||||||
GOTEST=@./utils/test/go-test-color.sh
|
GOTEST=@./utils/test/go-test-color.sh
|
||||||
PACK=$(shell command -v pack 2> /dev/null)
|
PACK=$(shell command -v pack 2> /dev/null)
|
||||||
RUN=$(shell command -v run 2> /dev/null)
|
RUN=$(shell command -v run 2> /dev/null)
|
||||||
SERVICEFILE=/etc/systemd/system/animenotifier.service
|
|
||||||
|
|
||||||
# Determine the name of the platform
|
# Determine the name of the platform
|
||||||
OSNAME=
|
OSNAME=
|
||||||
@ -21,45 +20,30 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Build targets
|
# builds the server executable
|
||||||
server:
|
server:
|
||||||
@go build -v
|
@go build -v
|
||||||
deps:
|
|
||||||
go mod download
|
# installs development tools
|
||||||
jobs:
|
|
||||||
@./jobs/build.sh
|
|
||||||
bots:
|
|
||||||
@./bots/build.sh
|
|
||||||
patches:
|
|
||||||
@./patches/build.sh
|
|
||||||
test:
|
|
||||||
$(GOTEST) github.com/animenotifier/notify.moe -v -cover
|
|
||||||
bench:
|
|
||||||
$(GOTEST) -bench .
|
|
||||||
pack:
|
|
||||||
go install github.com/aerogo/pack/...
|
|
||||||
run:
|
|
||||||
go install github.com/aerogo/run/...
|
|
||||||
tools:
|
tools:
|
||||||
ifeq ($(OSNAME),OSX)
|
ifeq ($(OSNAME),OSX)
|
||||||
brew install coreutils
|
brew install coreutils
|
||||||
endif
|
endif
|
||||||
@make pack
|
go install github.com/aerogo/pack/...
|
||||||
@make run
|
go install github.com/aerogo/run/...
|
||||||
service:
|
|
||||||
sudo cp systemd.service $(SERVICEFILE)
|
# compiles assets for the server
|
||||||
sudo sed -i "s|MAKEFILE_USER|$(USER)|g" $(SERVICEFILE)
|
|
||||||
sudo sed -i "s|MAKEFILE_PWD|$(PWD)|g" $(SERVICEFILE)
|
|
||||||
sudo sed -i "s|MAKEFILE_EXEC|$(PWD)/notify.moe|g" $(SERVICEFILE)
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
@echo -e "\nYou can now start the service using:\n\nsudo systemctl start animenotifier.service"
|
|
||||||
assets:
|
assets:
|
||||||
@tsc
|
@tsc
|
||||||
@pack
|
@pack
|
||||||
|
|
||||||
|
# cleans all binaries and generated files
|
||||||
clean:
|
clean:
|
||||||
find . -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs rm
|
find . -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs rm
|
||||||
find . -type f | grep /scripts/ | grep .js | xargs rm
|
find . -type f | grep /scripts/ | grep .js | xargs rm
|
||||||
rm -rf ./components
|
rm -rf ./components
|
||||||
|
|
||||||
|
# forwards local ports 80 and 443 to 4000 and 4001
|
||||||
ports:
|
ports:
|
||||||
ifeq ($(OSNAME),LINUX)
|
ifeq ($(OSNAME),LINUX)
|
||||||
@sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 4000
|
@sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 4000
|
||||||
@ -70,6 +54,29 @@ endif
|
|||||||
ifeq ($(OSNAME),OSX)
|
ifeq ($(OSNAME),OSX)
|
||||||
@echo "rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001" | sudo pfctl -ef -
|
@echo "rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001" | sudo pfctl -ef -
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# installs systemd service files for all required services
|
||||||
|
services:
|
||||||
|
@./services/build.sh
|
||||||
|
|
||||||
|
# builds all background jobs
|
||||||
|
jobs:
|
||||||
|
@./jobs/build.sh
|
||||||
|
|
||||||
|
# builds all bots
|
||||||
|
bots:
|
||||||
|
@./bots/build.sh
|
||||||
|
|
||||||
|
# builds all patches
|
||||||
|
patches:
|
||||||
|
@./patches/build.sh
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(GOTEST) github.com/animenotifier/notify.moe -v -cover
|
||||||
|
|
||||||
|
bench:
|
||||||
|
$(GOTEST) -run=^$ -bench .
|
||||||
|
|
||||||
all: tools assets server bots jobs patches
|
all: tools assets server bots jobs patches
|
||||||
|
|
||||||
.PHONY: tools assets server bots jobs patches ports clean versions
|
.PHONY: tools assets server bots jobs patches services ports clean
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
MYDIR="$(dirname "$(readlink -f "$0")")"
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
cd "$MYDIR"
|
cd "$SCRIPTPATH"
|
||||||
for dir in ./*; do ([ -d "$dir" ] && cd "$dir" && echo "Building patches/$dir" && go build); done
|
|
||||||
|
for dir in *; do
|
||||||
|
[ -d "$SCRIPTPATH/$dir" ] &&
|
||||||
|
cd "$SCRIPTPATH/$dir" &&
|
||||||
|
echo "Building patches/$dir" &&
|
||||||
|
go build
|
||||||
|
done
|
@ -5,14 +5,9 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=MAKEFILE_USER
|
User=MAKEFILE_USER
|
||||||
ExecStart=MAKEFILE_EXEC
|
ExecStart=MAKEFILE_PWD/notify.moe
|
||||||
WorkingDirectory=MAKEFILE_PWD
|
WorkingDirectory=MAKEFILE_PWD
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
#Nice=-19
|
|
||||||
#CPUSchedulingPolicy=fifo
|
|
||||||
#CPUSchedulingPriority=99
|
|
||||||
#IOSchedulingClass=realtime
|
|
||||||
#IOSchedulingPriority=0
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
14
services/build.sh
Executable file
14
services/build.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
INSTALLPATH="/etc/systemd/system/"
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
for service in *; do
|
||||||
|
[ -f "$service" ] &&
|
||||||
|
echo "Installing services/$service" &&
|
||||||
|
sudo cp "services/$service" "$INSTALLPATH/$service" &&
|
||||||
|
sudo sed -i "s|MAKEFILE_USER|$USER|g" "$INSTALLPATH/$service" &&
|
||||||
|
sudo sed -i "s|MAKEFILE_PWD|$PWD|g" "$INSTALLPATH/$service"
|
||||||
|
done
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
echo -e "\nYou can now start the service using:\n\nsudo systemctl start animenotifier.service"
|
13
services/discord.service
Normal file
13
services/discord.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Discord Bot
|
||||||
|
After=animenotifier.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=MAKEFILE_USER
|
||||||
|
ExecStart=MAKEFILE_PWD/bots/discord/discord
|
||||||
|
WorkingDirectory=MAKEFILE_PWD
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
0
services/imageserver.service
Normal file
0
services/imageserver.service
Normal file
0
services/japanese.service
Normal file
0
services/japanese.service
Normal file
13
services/jobs.service
Normal file
13
services/jobs.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Background Jobs
|
||||||
|
After=animenotifier.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=MAKEFILE_USER
|
||||||
|
ExecStart=MAKEFILE_PWD/jobs/jobs
|
||||||
|
WorkingDirectory=MAKEFILE_PWD
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user