2022-09-20 21:49:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# the launcher file will launch the correct app / worker based on the given env variable
|
|
|
|
# the main goal of that launcher is to be used as a Docker entrypoint
|
2022-09-21 21:18:12 +00:00
|
|
|
# APP_TYPE: Can be api, worker or cron
|
2022-09-20 21:49:37 +00:00
|
|
|
|
|
|
|
case "$APP_TYPE" in
|
|
|
|
{{ if eq (len .APIs) 1 }}
|
|
|
|
# API
|
|
|
|
api) exec /app/{{ (index .APIs 0).Binary }} ;;
|
|
|
|
{{ else if gt (len .APIs) 1 }}
|
|
|
|
{{range .APIs}}
|
|
|
|
# API {{.Name}}
|
|
|
|
{{.Name}}) exec /app/{{.Binary}} ;;
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{- if ne (len .Workers) 0 }}
|
|
|
|
# Workers
|
|
|
|
worker)
|
|
|
|
case "$WORKER_NAME" in
|
|
|
|
|
|
|
|
{{range .Workers}}
|
|
|
|
# Worker {{.Name}}
|
|
|
|
{{.Name}}) exec /app/{{.Binary}} ;;
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
# otherwise
|
|
|
|
*)
|
|
|
|
echo "** invalid WORKER_NAME='$WORKER_NAME'. Please use a valid worker name!"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
{{end}}
|
2022-09-21 21:18:12 +00:00
|
|
|
|
|
|
|
{{- if ne (len .Crons) 0 }}
|
|
|
|
# Crons
|
|
|
|
cron)
|
|
|
|
case "$CRON_NAME" in
|
|
|
|
|
|
|
|
{{range .Crons}}
|
|
|
|
# Cron {{.Name}}
|
|
|
|
{{.Name}}) exec /app/{{.Binary}} ;;
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
# otherwise
|
|
|
|
*)
|
|
|
|
echo "** invalid CRON_NAME='$CRON_NAME'. Please use a valid cron name!"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
{{end}}
|
|
|
|
|
2022-09-20 21:49:37 +00:00
|
|
|
# otherwise
|
|
|
|
*)
|
2022-09-21 21:18:12 +00:00
|
|
|
echo "** invalid APP_TYPE='$APP_TYPE' ! Please use API, WORKER or CRON!"
|
2022-09-20 21:49:37 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|