Run command to disable another run (background) process


Is it currently possible to terminate a run step (running a background process) from another run step?

For example, my config file runs a server and tests afterwards:

  - run:
      name: Run Servers
      command: python runservers
      background: true

  - run:
      name: Test
      command: make tests

Is there currently any capability that can terminate my server step running in the background, after my tests complete? e.g.

  - run:
      name: Test
      command: |
         make tests
         stop "Run Servers"


I imagine so. I’d start with trying killall python, but bear in mind this will only be useful if that’s the only Python task in your build server. If you want something more granular, you can grep the output of ps to get the right PID to kill.

Of course, if your script has a parameter to bring servers down cleanly, you should use that in preference.


Thank you for your help! I ended up just letting CircleCI cancel the step because killing the process with killall python or the PID kill, exits with an error code. Might implement a cleaner exit in the future but for now it should be ok.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.