1

I want to automate a deployment which includes starting a Minio server. However, when I start the Minio server with minio server myserver there is a process running which I usually would kill with Ctrl+C and go on with the next steps of the deployment.

Now I am writing a bash script that will automate all of these steps for me but I cannot get over that point when I create the minio server.

What I tried:

#!/usr/bin/env bash
git clone https://github.com/openfaas/faas
docker swarm init
cd faas && ./deploy_stack.sh --no-auth
minio server myserver && kill $(pgrep minio server myserver)
cd data && mc mb incoming && mc mb processed

How can I kill this process within the same bash script?

nymvno
  • 370
  • 5
  • 19
  • I don't see `minio server mysever` in the provided code, also which running process would you normally SIGINT with Ctrl+C? – Shardj May 08 '19 at 16:16
  • I edited it since before the server was named 'data'. Normally, when running minio server myserver the server process would start and also add a directory for that server. I just want to have that folder at this moment and would consequently kill this process to go on in the same terminal. Now I want to automate these steps with a bash script. – nymvno May 08 '19 at 16:33
  • `minio server myserver & minio_pid=$!` runs the server in the background and stores its PID (assuming it isn't self-daemonizing; if it is, turn that off); then, whenever you want to kill it, `kill "$minio_pid"` signals that stored PID. – Charles Duffy May 08 '19 at 16:34
  • ...that said, killing the server an instant after you start it seems... surprising? What's the actual use case here? If you need to let it start up for a few seconds for the side effects, f/e, then you might actually want `minio server myserver & minio_pid=$!; sleep 2; kill "$minio_pid"` to actually allow that delay. Without any delay, whatever you mean to accomplish by briefly starting the server is likely not to happen at all. – Charles Duffy May 08 '19 at 16:34
  • I did manage to solve this with all of your help. Thank you so much! – nymvno May 08 '19 at 16:52

0 Answers0