1

I am using docker to create a tcserver instance and it is successfully stopped when I do

./tcruntime-ctl.sh stop

However, the instance is not successfully restarted when I do

./tcruntime-ctl.sh run

The reason being that PID file(PID=1) still present and not deleted

Please note that I am running the tcserver instance as a foreground process by using the run command

meallhour
  • 13,921
  • 21
  • 60
  • 117
  • maybe you can use https://github.com/phusion/baseimage-docker to avoid the PID 1 pb? Can you show a reproducer? Would `docker run --restart=always` help? The doc for docker run https://docs.docker.com/engine/reference/commandline/cli/#run – user2915097 Dec 21 '15 at 17:59
  • If I do `docker run --restart=always` it will restart the container if docker daemon is restarted. I don't want that. By, the way what you mean by reproducer?? – meallhour Dec 21 '15 at 21:15
  • Another option could be `ENTRYPOINT tcruntime-ctl.sh start && tail -f /dev/null` However, this will run tcserver as a background process and in such a case, how to make sure that the container also dies when the tcserver instance is stopped?? – meallhour Dec 21 '15 at 21:30
  • Can i use `STOPSIGNAL` instruction here?? @user2915097 – meallhour Dec 21 '15 at 21:45
  • A reproducer means enough details so that I can launch the exact same process – user2915097 Dec 21 '15 at 22:13
  • After installing tcserver, I am creating a tcserver template. Then, I am trying to run an instance of tcserver using `./tcruntime-ctl.sh run` When, I do `docker stop CONTAINER_ID` the container is stopped. Now, when I do `docker start CONTAINER_ID` the container is not started and i cannot see the container using `docker ps' @user2915097 – meallhour Dec 21 '15 at 22:38
  • Check `docker events` – user2915097 Dec 22 '15 at 14:40

1 Answers1

0

If the error is simply that there is a vestige pidfile from a previous run, a workaround can be to remove the pidfile before invoking the tcruntime-ctl.sh script. Since the the lifespan of the tcServer instance is related to that of the docker container, it can be safely assumed the process referred to in the pidfile has previously exited. You could write your own script that cleans up prior to execing tcruntime.sh, or prepend something like the following:

#!/bin/sh

pidfile=$(dirname $0)/../logs/tcserver.pid
if [ -f $pidfile ] ; then
    rm $pidfile
fi