@@ -10,232 +10,18 @@ It is hosted on:
10
10
11
11
- [ api.interflux.com] ( https://api.interflux.com )
12
12
13
- Build status:
14
-
15
- | ` master ` | ` production ` |
16
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
- | [ ![ Build status] ( https://badge.buildkite.com/feec3c1bb9d5fa10832931944a2af6a98fa4d2225c3b002045.svg?branch=master )] ( https://buildkite.com/nabu/api-dot-interflux-dot-com ) | [ ![ Build status] ( https://badge.buildkite.com/feec3c1bb9d5fa10832931944a2af6a98fa4d2225c3b002045.svg?branch=production )] ( https://buildkite.com/nabu/api-dot-interflux-dot-com ) |
18
-
19
13
## Development
20
14
21
- Setup on Mac:
22
-
23
- ```
24
- brew update
25
- brew install rbenv ruby-build
26
- ```
27
-
28
- Someone suggest to then add ` rbenv ` to path, but no need...
29
-
30
- ```
31
- set --universal fish_user_paths $fish_user_paths ~/.rbenv/shims
32
- ```
33
-
34
- Instead:
35
-
36
- ```
37
- rbenv init
38
- ```
39
-
40
- Suggest to add the following to Fish config:
41
-
42
- ```
43
- atom ~/.config/fish/config.fish
44
- status --is-interactive; and source (rbenv init -|psub)
45
- ```
46
- ```
47
- brew install postgresql
48
- brew services start postgresql
49
- ```
50
- ```
51
- git clone [email protected] :janwerkhoven/api.interflux.com.git
52
- cd api.interflux.com
53
- rbenv install -s
54
- rbenv rehash
55
- gem install bundler
56
- gem install rails
57
- bin/bundle install
58
- bin/rails db:drop;
59
- bin/rails db:create
60
- bin/rails db:migrate
61
- bin/rails db:environment:set RAILS_ENV=development;
62
- bin/rails db:create;
63
- bin/rails db:migrate;
64
- bin/rails db:fixtures:load;
65
- ```
66
-
67
- Fire up Rails:
68
-
69
- ```
70
- bin/rails s
71
- ```
72
-
73
- Access console:
74
-
75
- ```
76
- bin/rails c
77
- ```
78
-
79
- Seed database with fixtures:
80
-
81
- ```
82
- bin/rails db:fixtures:load FIXTURES=articles
83
- ```
84
-
85
- Generate custom scaffold for new resource:
86
-
87
- ```
88
- bin/rails generate custom_scaffold related_things --version=v1 --scope=admin
89
- ```
90
-
91
- Drop database and start over:
92
-
93
- ```
94
- bin/rails db:environment:set RAILS_ENV=development;
95
- bin/rails db:drop;
96
- bin/rails db:create;
97
- bin/rails db:migrate;
98
- bin/rails db:seed
99
- ```
100
-
101
- Create user:
102
-
103
- ```
104
- bin/rails c
105
- p = Person.create(first_name:'Jan', last_name:'Werkhoven')
106
- User.create(email:'[email protected] ', password: '12345678', person_id: p.id)
107
- ```
108
-
109
- Test login:
110
-
111
- ```
112
- curl \
113
- -X POST \
114
- -H "Content-Type: application/vnd.api+json" \
115
- -d '{ "email": "[email protected] ", "password": 12345678 }' \
116
- http://localhost:3000/v1/admin/auth/login
117
-
118
- set token TOKEN
119
-
120
- curl \
121
- -X GET \
122
- -H "Content-Type: application/vnd.api+json" \
123
- -H "Authorization: $token" \
124
- http://localhost:3000/v1/admin/leads
125
- ```
126
-
127
- Roll back a migration:
128
-
129
- ```
130
- bin/rails db:rollback STEP=1
131
- ```
132
-
133
- Sanity check:
134
-
135
- ```
136
- curl \
137
- -X GET \
138
- -H "Content-Type: application/vnd.api+json" \
139
- http://localhost:3000/sanity-check
140
- ```
15
+ Refer to ` wiki/development.sh ` .
141
16
142
17
## Production
143
18
144
- Manual deploy to production (from local):
145
-
146
- ```
147
- ./deploy.sh
148
- ```
149
-
150
- Control Puma:
151
-
152
- ```
153
- bin/pumactl -F config/puma/production.rb -T '12345' start
154
- bin/pumactl -F config/puma/production.rb -T '12345' stop
155
- bin/pumactl -F config/puma/production.rb -T '12345' phased-restart
156
- ```
157
-
158
- Access production console:
159
-
160
- ```
161
- bin/rails console production
162
- ```
163
-
164
- Seed production database with fixtures:
165
-
166
- ```
167
- export RAILS_ENV=production
168
- bin/rails db:seed
169
- ```
170
-
171
- Backup and drop production database:
172
-
173
- ```
174
- env RAILS_ENV=production rake db:data:dump
175
- [email protected] :/var/www/api.interflux.com/builds/feature/authentication/cd977ad/db/data.yml .
176
- ```
177
-
178
- ```
179
- bin/rails db:data:dump
180
- bin/pumactl -F config/puma/production.rb -T '12345' stop
181
- export RAILS_ENV=production;
182
- export DISABLE_DATABASE_ENVIRONMENT_CHECK=1;
183
- bin/rails db:drop
184
- ```
185
-
186
- Health check:
187
-
188
- ```
189
- curl https://api.interflux.com/status
190
- ```
191
-
192
- This should return you a 200 with JSON payload. The API is down if it doesn't!
19
+ Refer to ` wiki/production.sh ` .
193
20
194
21
## Testing
195
22
196
- Test all:
197
-
198
- ```
199
- bin/rails t
200
- bin/rails test
201
- bin/rails test --verbose
202
- ```
203
-
204
- Test specific folder:
205
-
206
- ```
207
- bin/rails test test/integration/v1/public/*
208
- ```
209
-
210
- Test specific file:
211
-
212
- ```
213
- bin/rails test test/integration/v1/public/products_integration_test.rb
214
- ```
215
-
216
- Test specific test (add line number):
217
-
218
- ```
219
- bin/rails test test/integration/v1/public/products_integration_test.rb:22
220
- ```
221
-
222
- ## Trouble shooting
223
-
224
- ` PG::ConnectionBad `
225
-
226
- Check if Postgress is running.
227
-
228
- ` EADDRINUSE `
229
-
230
- Port 3000 is already taken by another process. This is most likely a rogue Puma
231
- process that wasn't stopped properly. Find the process ID (pid) by running:
232
-
233
- ```
234
- sudo lsof -iTCP -sTCP:LISTEN -P
235
- ```
23
+ Refer to ` wiki/testing.sh ` .
236
24
237
- Then kill the one listening to port 3000:
25
+ ## Postgress
238
26
239
- ```
240
- kill -9 [pid]
241
- ```
27
+ Refer to ` wiki/postgres.sh ` .
0 commit comments