all: init user message location websocket gateway

init:
	mkdir -p /opt/api-user && \
		mkdir -p /opt/api-message && \
		mkdir -p /opt/api-location && \
		mkdir -p /opt/api-websocket && \
		mkdir -p /opt/app-gateway
	cp -f ./api-user/api-user.service /etc/systemd/system/api-user.service && \
		cp -f ./api-message/api-message.service /etc/systemd/system/api-message.service && \
		cp -f ./api-location/api-location.service /etc/systemd/system/api-location.service && \
		cp -f ./api-websocket/api-websocket.service /etc/systemd/system/api-websocket.service && \
		cp -f ./app-gateway/app-gateway.service /etc/systemd/system/app-gateway.service && \
		sudo systemctl daemon-reload

gateway: init
	./gradlew :app-gateway:clean :app-gateway:bootJar
	cp ./app-gateway/build/libs/app-gateway-1.0.1.jar /opt/app-gateway/app-gateway.jar
	sudo systemctl restart app-gateway

user: init
	./gradlew :api-user:clean :api-user:bootJar
	cp ./api-user/build/libs/api-user-1.0.1.jar /opt/api-user/api-user.jar
	sudo systemctl restart api-user

message: init
	./gradlew :api-message:clean :api-message:bootJar
	cp ./api-message/build/libs/api-message-1.0.1.jar /opt/api-message/api-message.jar
	sudo systemctl restart api-message

location: init
	./gradlew :api-location:clean :api-location:bootJar
	cp ./api-location/build/libs/api-location-1.0.1.jar /opt/api-location/api-location.jar
	sudo systemctl restart api-location

websocket: init
	./gradlew :api-websocket:clean :api-websocket:bootJar
	cp ./api-websocket/build/libs/api-websocket-1.0.1.jar /opt/api-websocket/api-websocket.jar
	sudo systemctl restart api-websocket