Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command dependencies #41

Closed
luetge opened this issue May 29, 2018 · 2 comments
Closed

Command dependencies #41

luetge opened this issue May 29, 2018 · 2 comments

Comments

@luetge
Copy link

luetge commented May 29, 2018

Hi,

the following is an idea to allow dependence of processes on unix commands: instead of the keyword "require" to list a number of immortal processes as dependencies one could introduce a keyword "require_cmd", which specifies a list of unix commands that are executed and have to return without errors (exit code 0) in order for the immortal process to start. Immortal would then automatically check this periodically, and as soon as these dynamic conditions are fulfilled, the process would be spawned.

Use case: spawn a process when a certain file exists/does not exist anymore.

Thank you!

@nbari
Copy link
Member

nbari commented Jun 8, 2018

@luetge please check latest release 0.20.0 it has implemented this feature 👍

For testing in mac:

 $ brew install immortal

create a supervisor dir:

 mkdir /tmp/immortal

set the enviroment IMMORTAL_SDIR to that directory:

 export IMMORTAL_SDIR=/tmp/immortal

add this environment in all terminals you use in case want to use immortaldir so that immortalctl can read/know where are the sockets for the processes

Create a dir to scan (in where your run.yml files will be):

mkdir $HOME/tmp/services

Start immortaldir on that directory:

immortaldir $HOME/tmp/services

Create a test run.yml file in $HOME/tmp/services, something like:

cmd: iostat 3
log:
    file: /tmp/iostat.log
require_cmd: test -f /tmp/foo

It should not start until you create the file /tmp/foo, so you could test immortalctl should not print any process, later do touch /tmp/foo and it should start the process.

Please give a try and let me know how it goes.

@luetge
Copy link
Author

luetge commented Jun 13, 2018

That works perfectly, thank you! (Tested on MacOS)

@luetge luetge closed this as completed Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants