Evening,
I am trying to keep a spawn process that normally attaches to process id 1 wheb running. However because ansible kills all entries in a process group i have been told to use async.
However do i wait for the async process to complete before starting the next task? Does setting a poll time of 0 ensure that the task is completed before the next task has started, or does it just run it as a background task forever without reporting it state.
Reason for asking is that i am trying to start a weblogic process that detaches to process 1 but shell/command detaches it the root process group. Nohup returns straight away and starts the next task which is dependant on the previous task running.
Any ideas on the best way to do this?
Regards
Nicholas Irving
i would not start a service in a 'non service fashion' if you don't
want to write an init script you should use at least something like
monit/daemontools/runit/supervisorctl to manage the service.
Otherwise you will find yourself manually trying to figure out 'is it
running?' 'is there more than 1 running?' 'can i stop it?' etc...
Brian
You are missing the point.
If i run a command on the server and it decides to become a background process then when i run that same command via ansible the outcome should be the same. I should not have to code around the issue because ansible spawns and kills process groups.
I expect ansible to be a like for like replacement of me running the commands direct on the server. Otherwise i have to compromise and rewrite the delivery of a service that has been working for years.
I understand where you are coming from, but when you are dealing with an imperfect world where people say but i can do it this way, it makes ansible a hard sell if it is hard to use.
Regards
Nicholas Irving
So a few things here.
Having just breezed over what WebLogic Node Runner does, I see where something like service or supervisor is somewhat redundent for you. That wasn't clear to me from from this thread until I did that though. That's not the norm for most though and you weren't clear on that so I don't think its fair to say Brian is missing the point.
So I think I get what you are trying to do.
We've been in a similar spot here with long running processes rather than daemons, but I think what we did applies here. Use the the wait_for directive right after your shell nohup async task and look for a sign that the initialization of the previous task has reached a ready state. What is "ready" will depend on you. In our case it's a specific line in a log file.
Not ideal or elegant, but it should work.
Now, based on what I read, it sounds like the elegant solution would be to create a noderunner module where you can better manage and control the jobs abstracted from your playbook or role.
Hope that helps.
HI Timothy
Sorry if it was not made clear, I thought I had stated that the process attaches to the Process ID 1 when running from the command line. I was trying to talk in general terms and not about a specific instance, as once this is solved it is a patten that can be applied to other similar processes.
The thing is that the process is not long running, it initially creates a process then attaches it to Process ID 1 and then exits. So if you ran it from the command line it would initialise the process and then make it run in the background so that it is not killed when the shell is exited.
What I have found is a script that starts the process using nohup and & to spawn the process in the background and survives shell exit etc, and then waits for the port to be active. In this way ansible can run the shell / command and pseudo wait for the process to complete. Just because the port is active may not mean the process has been successful, that is hidden in the messages being generated to a file. I can then replay the file back to STDOUT and get ansible to check it was okay.
In effect i have a wrapper that is ansible friendly, just now I have to sell this to the rest of my team that this pattern is the way we need to move forward, as this helps bootstrap the application being deployed.
I have an actual service that I manage through init.d, but it does a lot more than just start the process, in fact it performs 2 other tasks, but this is not something that I can change, not without major testing.
I apologise to people if anybody took offence to what I have said.
Regards
Nicholas Irving