-
Notifications
You must be signed in to change notification settings - Fork 9
/
deploy.sh
executable file
·78 lines (63 loc) · 1.99 KB
/
deploy.sh
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
72
73
74
75
76
77
78
#!/bin/sh
# UUID="00277430-85b5-46e2-a6c9-4fe3da538187"
# APP_NAME="lyz7805-v2ray"
REGION="lax"
if ! command -v flyctl >/dev/null 2>&1; then
printf '\e[33mCould not resolve command - flyctl. So, install flyctl first.\n\e[0m'
curl -L https://fly.io/install.sh | FLYCTL_INSTALL=/usr/local sh
fi
if [ -z "${APP_NAME}" ]; then
printf '\e[31mPlease set APP_NAME first.\n\e[0m' && exit 1
fi
flyctl info --app "${APP_NAME}" >/tmp/${APP_NAME} 2>&1;
if [ "$(cat /tmp/${APP_NAME} | grep -o "Could not resolve App")" = "Could not resolve App" ]; then
printf '\e[33mCould not resolve app. Next, create the App.\n\e[0m'
flyctl apps create "${APP_NAME}" >/dev/null 2>&1;
flyctl info --app "${APP_NAME}" >/tmp/${APP_NAME} 2>&1;
if [ "$(cat /tmp/${APP_NAME} | grep -o "Could not resolve App")" != "Could not resolve App" ]; then
printf '\e[32mCreate app success.\n\e[0m'
else
printf '\e[31mCreate app failed.\n\e[0m' && exit 1
fi
else
printf '\e[33mThe app has been created.\n\e[0m'
fi
printf '\e[33mNext, create app config file - fly.toml.\n\e[0m'
cat <<EOF >./fly.toml
app = "$APP_NAME"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 443
# processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 50
soft_limit = 35
type = "connections"
[[services.ports]]
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "120s"
interval = "15s"
restart_limit = 0
timeout = "2s"
EOF
printf '\e[32mCreate app config file success.\n\e[0m'
printf '\e[33mNext, set app secrets and regions.\n\e[0m'
flyctl secrets set UUID="${UUID}"
flyctl regions set ${REGION}
printf '\e[32mApp secrets and regions set success. Next, deploy the app.\n\e[0m'
flyctl deploy --detach
# flyctl status --app ${APP_NAME}