The machine instances running for Travis CI start some services by default which are not useful to my project. Therefore I want to stop these services. My first idea was to use the following block in my .travis.yml to do so:
before_script:
# Disable services enabled by default
- sudo service mysql stop
- sudo service postgresql stop
However, this was successful for one and failed for another machine:
$ sudo service mysql stop
mysql stop/waiting
$ sudo service postgresql stop
* Stopping PostgreSQL 9.1 database server
...done.
* Stopping PostgreSQL 9.2 database server
...done.
* Stopping PostgreSQL 9.3 database server
...done.
...
$ sudo service mysql stop
stop: Unknown instance:
The command "sudo service mysql stop" failed and exited with 1 during .
Another option is /etc/init.d/mysql stop
but this could fail on a machine which started the process via the service
command. Is there a try-catch I can use in the .travis.yml script?