|
34 | 34 | from pants.engine.unions import UnionRule |
35 | 35 | from pants.util.logging import LogLevel |
36 | 36 |
|
37 | | -from uses_services.exceptions import ServiceMissingError |
| 37 | +from uses_services.exceptions import ServiceMissingError, ServiceSpecificMessages |
38 | 38 | from uses_services.platform_rules import Platform |
39 | 39 | from uses_services.scripts.is_mongo_running import ( |
40 | 40 | __file__ as is_mongo_running_full_path, |
@@ -159,123 +159,41 @@ async def mongo_is_running( |
159 | 159 | return MongoIsRunning() |
160 | 160 |
|
161 | 161 | # mongo is not running, so raise an error with instructions. |
162 | | - |
163 | | - if platform.distro in ["centos", "rhel"] or "rhel" in platform.distro_like: |
164 | | - instructions = dedent( |
165 | | - """\ |
166 | | - If mongo is installed, but not running try: |
167 | | -
|
168 | | - """ |
169 | | - ) |
170 | | - |
171 | | - if platform.distro_major_version == "7": |
172 | | - instructions += "\nservice mongo start\n" |
173 | | - else: |
174 | | - instructions += "\nsystemctl start mongod\n" |
175 | | - |
176 | | - instructions += dedent( |
177 | | - """ |
178 | | - If mongo is not installed, this is one way to install it: |
179 | | -
|
180 | | - # Add key and repo for the latest stable MongoDB (4.0) |
181 | | - rpm --import https://www.mongodb.org/static/pgp/server-4.0.asc |
182 | | - sh -c "cat <<EOT > /etc/yum.repos.d/mongodb-org-4.repo |
183 | | - [mongodb-org-4] |
184 | | - name=MongoDB Repository |
185 | | - baseurl=https://repo.mongodb.org/yum/redhat/${OSRELEASE_VERSION}/mongodb-org/4.0/x86_64/ |
186 | | - gpgcheck=1 |
187 | | - enabled=1 |
188 | | - gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc |
189 | | - EOT" |
190 | | - # Install mongo |
191 | | - yum install mongodb-org |
192 | | - # Don't forget to start mongo. |
193 | | - """ |
194 | | - ) |
195 | | - elif platform.distro in ["ubuntu", "debian"] or "debian" in platform.distro_like: |
196 | | - instructions = dedent( |
197 | | - """\ |
198 | | - If mongo is installed, but not running try: |
199 | | -
|
200 | | - systemctl start mongod |
201 | | -
|
202 | | - If mongo is not installed, this is one way to install it: |
203 | | -
|
204 | | - apt-get install mongodb mongodb-server |
205 | | - # Don't forget to start mongo. |
206 | | - """ |
207 | | - ) |
208 | | - elif platform.os == "Linux": |
209 | | - instructions = dedent( |
210 | | - f"""\ |
211 | | - You are on Linux using {platform.distro_name}, which is not |
212 | | - one of our generally supported distributions. We recommend |
213 | | - you use vagrant for local development with something like: |
214 | | -
|
215 | | - vagrant init stackstorm/st2 |
216 | | - vagrant up |
217 | | - vagrant ssh |
218 | | -
|
219 | | - Please see: https://docs.stackstorm.com/install/vagrant.html |
220 | | -
|
221 | | - For anyone who wants to attempt local development without vagrant, |
222 | | - you are pretty much on your own. At a minimum you need to install |
223 | | - and start mongo with something like: |
224 | | -
|
225 | | - systemctl start mongod |
226 | | -
|
227 | | - We would be interested to hear about alternative distros people |
228 | | - are using for development. If you are able, please let us know |
229 | | - on slack which distro you are using: |
230 | | -
|
231 | | - Arch: {platform.arch} |
232 | | - Distro: {platform.distro} |
233 | | - Distro Name: {platform.distro_name} |
234 | | - Distro Codename: {platform.distro_codename} |
235 | | - Distro Family: {platform.distro_like} |
236 | | - Distro Major Version: {platform.distro_major_version} |
237 | | - Distro Version: {platform.distro_version} |
238 | | -
|
239 | | - Thanks and Good Luck! |
240 | | - """ |
241 | | - ) |
242 | | - elif platform.os == "Darwin": # MacOS |
243 | | - instructions = dedent( |
244 | | - """\ |
245 | | - You are on Mac OS. Generally we recommend using vagrant for local |
246 | | - development on Mac OS with something like: |
247 | | -
|
248 | | - vagrant init stackstorm/st2 |
249 | | - vagrant up |
250 | | - vagrant ssh |
251 | | -
|
252 | | - Please see: https://docs.stackstorm.com/install/vagrant.html |
253 | | -
|
254 | | - For anyone who wants to attempt local development without vagrant, |
255 | | - you may run into some speed bumps. Others StackStorm developers have |
256 | | - been known to use Mac OS for development, so feel free to ask for |
257 | | - help in slack. At a minimum you need to install and start mongo. |
258 | | - """ |
259 | | - ) |
260 | | - else: |
261 | | - instructions = dedent( |
262 | | - """\ |
263 | | - You are not on Linux. In this case we recommend using vagrant |
264 | | - for local development with something like: |
265 | | -
|
266 | | - vagrant init stackstorm/st2 |
267 | | - vagrant up |
268 | | - vagrant ssh |
269 | | -
|
270 | | - Please see: https://docs.stackstorm.com/install/vagrant.html |
271 | | -
|
272 | | - For anyone who wants to attempt local development without vagrant, |
273 | | - you are pretty much on your own. At a minimum you need to install |
274 | | - and start mongo. Good luck! |
275 | | - """ |
276 | | - ) |
277 | | - |
278 | | - raise ServiceMissingError("mongo", platform, instructions) |
| 162 | + raise ServiceMissingError( |
| 163 | + platform, |
| 164 | + ServiceSpecificMessages( |
| 165 | + service="mongo", |
| 166 | + service_start_cmd_el_7="service mongo start", |
| 167 | + service_start_cmd_el="systemctl start mongod", |
| 168 | + not_installed_clause_el="this is one way to install it:", |
| 169 | + install_instructions_el=dedent( |
| 170 | + """\ |
| 171 | + # Add key and repo for the latest stable MongoDB (4.0) |
| 172 | + rpm --import https://www.mongodb.org/static/pgp/server-4.0.asc |
| 173 | + sh -c "cat <<EOT > /etc/yum.repos.d/mongodb-org-4.repo |
| 174 | + [mongodb-org-4] |
| 175 | + name=MongoDB Repository |
| 176 | + baseurl=https://repo.mongodb.org/yum/redhat/${OSRELEASE_VERSION}/mongodb-org/4.0/x86_64/ |
| 177 | + gpgcheck=1 |
| 178 | + enabled=1 |
| 179 | + gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc |
| 180 | + EOT" |
| 181 | + # Install mongo |
| 182 | + yum install mongodb-org |
| 183 | + # Don't forget to start mongo. |
| 184 | + """ |
| 185 | + ), |
| 186 | + service_start_cmd_deb="systemctl start mongod", |
| 187 | + not_installed_clause_deb="this is one way to install it:", |
| 188 | + install_instructions_deb=dedent( |
| 189 | + """\ |
| 190 | + apt-get install mongodb mongodb-server |
| 191 | + # Don't forget to start mongo. |
| 192 | + """ |
| 193 | + ), |
| 194 | + service_start_cmd_generic="systemctl start mongod", |
| 195 | + ), |
| 196 | + ) |
279 | 197 |
|
280 | 198 |
|
281 | 199 | def rules(): |
|
0 commit comments