How to stop services on Travis CI by default?

The Travis CI machine instances run some services by default which are not useful for my project . Therefore, I want to stop these services. My first idea was to use the following block in my .travis.yml to do this:

before_script:
  # Disable services enabled by default
  - sudo service mysql stop
  - sudo service postgresql stop

      

However, this was successful for one and failed for the other 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 it might fail on the machine that started the process with the command service

. Is there a try-catch attempt I can use in the .travis.yml script?

+3


source to share


2 answers


It turns out that using the above /etc/init.d/ ...

works more reliably. There are some warnings about what to use sudo service ...

, but I have not been successful with them. So, this is what I am currently running:



language: android

jdk:
  - oraclejdk7
  - openjdk7

android:
  components:

    # All the build system components should be at the latest version
    - tools
    - platform-tools
    - build-tools-21.1.1
    - android-19

    # The libraries we can't get from Maven Central or similar
    - extra-android-support


notifications:
  email: true

before_script:

  # Disable services enabled by default
  # http://docs.travis-ci.com/user/database-setup/#MySQL
  - sudo /etc/init.d/mysql stop
  - sudo /etc/init.d/postgresql stop
  # The following did not work reliable
  # - sudo service mysql stop
  # - sudo service postgresql stop

  # Ensure Gradle wrapper is executable
  - chmod +x gradlew

  # Ensure signing configuration is present
  - mv app/gradle.properties.example app/gradle.properties

script:
  - ./gradlew clean assembleDebug

      

+3


source


sudo service mysql stop



I am using travis with laradock with mysql. And this team did the job for me.

0


source







All Articles