-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduction.sh
86 lines (54 loc) · 1.89 KB
/
production.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
79
80
81
82
83
84
85
86
# ---------
# DATABASE
# Back up the production database
remote/backup.sh
# Restore a production database
remote/restore-backup.sh "production-2022-03-09-013916-UTC"
# Seed production database
export RAILS_ENV=production
bin/rails db:seed
bin/rails db:seed:products
# Dump and download database
env RAILS_ENV=production rake db:data:dump
[email protected]:/var/www/api.interflux.com/builds/feature/authentication/cd977ad/db/data.yml .
# Drop production database
bin/rails db:data:dump
bin/pumactl -F config/puma/production.rb -T '12345' stop
export RAILS_ENV=production;
export DISABLE_DATABASE_ENVIRONMENT_CHECK=1;
bin/rails db:drop
# ---------
# CDN
# Sync up CdnFile in database with the actual files in the CDN
bin/rails cdn:sync
# ---------
# PUMA
# After server reboot
ssh [email protected] -i ~/.ssh/[email protected]
cd /var/www/api.interflux.com/builds/production/latest
bin/puma -e production
# which should do the same as:
# bin/puma --environment production
# bin/puma --config config/puma/production.rb
# Control Puma
bin/pumactl -F config/puma/production.rb -T '12345' start
bin/pumactl -F config/puma/production.rb -T '12345' stop
bin/pumactl -F config/puma/production.rb -T '12345' phased-restart
# Access production console
bin/rails console production
# ---------
# SANITY CHECKS
# From local
curl https://rails.api.interflux.com/sanity-check -H "Content-Type: application/vnd.api+json" | jq
# On server
curl --unix-socket /var/www/api.interflux.com/sockets/puma.sock https://api.interflux.com/sanity-check -H "Content-Type: application/vnd.api+json"
# ---------
# USERS
# First set the production environment flag
export RAILS_ENV=production
# Create user
bin/rails user:create email=foo@bar password=1234 first_name=John last_name=Doe
# Update password
bin/rails user:password email=foo@bar email=12345
# Delete user
bin/rails user:delete email=foo@bar