How to exit singularity "gracefully"

1,958 views
Skip to first unread message

Till

unread,
Jul 7, 2017, 6:56:46 PM7/7/17
to singularity
Hi, 

my %runscript starts 3 server processes as daemons 

1. http localhost:3002
2. mongod localhost:27017
3. node.js app localhost:3000

The last application that is launched is node. When I terminate node, singularity quits.
But I still have processes with open ports on my host system, because I did not quit
them properly from inside the container. Is there a good way of doing this kind of things?
Would it be possible to use some kind of init process like the one used in docker?
But that wouldn't work for multiple daemons, or?
Or is the best way of doing it, to shell into the container and start and stop everything manually?
Any ideas?

Thanks,

Till



Michael Bauer

unread,
Jul 7, 2017, 9:27:56 PM7/7/17
to singu...@lbl.gov
Hi Till,

In Singularity’s current state we do not have good support for daemon’s within the container. This means that, like you observed, the container does not exit gracefully when you have started daemon(s) within the container. However, I’m working on developing daemon support for Singularity and there is currently a working prototype.

If you would like to test out the changes, feel free to check out my work on my GitHub here: https://github.com/bauerm97/singularity/tree/sdaemon

Simply pull that branch and build it, and then proceed as follows with your container:

> singularity start [container.img]
> singularity run [container.img]

The singularity start command will open an “init” process within a PID namespace. The subsequent singularity run command will run your provided %runscript inside the container started by the start command. Please note, there is no stop functionality right now (still a prototype!), so you need to manually kill the init process to kill the container.

> ps aux | grep sinit

Using that command you can get the PID of the sinit process running.

> kill -n 9 [PID]

After you have the PID, sending a SIGKILL to the sinit process with that command will kill the sinit process. Then, your daemons will exit gracefully.

Please let me know if this works for you.

Thanks,
Michael

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity...@lbl.gov.

Stefan Kombrink

unread,
Jul 8, 2017, 6:28:18 AM7/8/17
to singularity
Hi Michael,

 how's it actually if I utilize the PID name space. Get all the processes killed in that case?

Stefan

Stefan Kombrink

unread,
Jul 8, 2017, 6:31:49 AM7/8/17
to singularity
Okay should better read the OT. The processes live on the host.
Actually I had related issues and did assume these are the same.
Like daemons which do not terminate properly when started in an interactive shell and exiting it.

Till

unread,
Jul 12, 2017, 12:57:15 AM7/12/17
to singu...@lbl.gov
Thank you Michael,

I didn't have the chance to test your, but I'll definitely give it a try when I'm back in the lab...

/till 



To unsubscribe from this group and stop receiving emails from it, send an email to singularity+unsubscribe@lbl.gov.

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity+unsubscribe@lbl.gov.
Reply all
Reply to author
Forward
0 new messages