Discussion:
[Supervisor-users] change working directory
Steve Piercy - Website Builder
2014-08-30 03:14:55 UTC
Permalink
Is there any way to change the working directory in a
[program:foo] stanza?

If that ain't possible, here's the problem I am trying to solve.

The binary program "foo" lacks documentation of how to start it
directly with the secret combination of correct flipped bits and
values. There are startup shell scripts available which set the
user, umask, and some environment variables (HOME, LC_ALL,
LD_LIBRARY_PATH), but every shell script changes the working
directory first, then invokes the command to start the binary:

./foo

When I try to start the binary with the fully qualified path
through Supervisor:

[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"

foo will start, but Supervisor cannot stop or restart it.

Any help would be immensely appreciated. Thank you!

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
<***@StevePiercy.com> <http://www.StevePiercy.com/>
Aryeh Leib Taurog
2014-08-30 18:27:06 UTC
Permalink
try this:

[program:foo]
command=./foo
directory=/usr/local/directory

<http://supervisord.org/configuration.html#program-x-section-example>
Is there any way to change the working directory in a [program:foo]
stanza?
If that ain't possible, here's the problem I am trying to solve.
The binary program "foo" lacks documentation of how to start it
directly with the secret combination of correct flipped bits and
values. There are startup shell scripts available which set the
user, umask, and some environment variables (HOME, LC_ALL,
LD_LIBRARY_PATH), but every shell script changes the working
./foo
When I try to start the binary with the fully qualified path through
[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"
foo will start, but Supervisor cannot stop or restart it.
Any help would be immensely appreciated. Thank you!
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Aryeh Leib Taurog
2014-08-30 18:41:26 UTC
Permalink
You must also make sure that foo is not daemonizing itself,
or supervisor will not be able to stop or restart it.

<http://supervisord.org/subprocess.html#nondaemonizing-of-subprocesses>
Is there any way to change the working directory in a [program:foo]
stanza?
If that ain't possible, here's the problem I am trying to solve.
The binary program "foo" lacks documentation of how to start it
directly with the secret combination of correct flipped bits and
values. There are startup shell scripts available which set the
user, umask, and some environment variables (HOME, LC_ALL,
LD_LIBRARY_PATH), but every shell script changes the working
./foo
When I try to start the binary with the fully qualified path through
[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"
foo will start, but Supervisor cannot stop or restart it.
Any help would be immensely appreciated. Thank you!
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Steve Piercy - Website Builder
2014-08-30 22:27:41 UTC
Permalink
Thanks. I tried it, but there is a problem.

The startup script has this:

sudo -u foo ./foo

and the stdout log for the program has:

sudo: sorry, you must have a tty to run sudo

I don't know how to work around that.

--steve
Steve,
You should be able to get Supervisor to manage the program ok
via a startup script as long as the script execs "foo" instead
of running it as a subprocess. Ie, the very last thing the
exec ./foo
The effect is that "foo" replaces the startup script as far as
Supervisor is concerned, so it will see SIGCHLD if "foo" exits
and a wait() will reap the exit status of "foo" itself, plus
the pid that Supervisor has will be foo's pid, so Supervisor
can send it signals.
That said, I'm on this list to learn more about Supervisor and
there may well be better ways to handle this case.
a.
Is there any way to change the working directory in a [program:foo] stanza?
If that ain't possible, here's the problem I am trying to solve.
The binary program "foo" lacks documentation of how to start it directly with the secret
combination of correct flipped bits and values. There are
startup shell scripts available which set the user, umask, and
some environment variables (HOME, LC_ALL, LD_LIBRARY_PATH), but
every shell script changes the working directory first, then
./foo
[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"
foo will start, but Supervisor cannot stop or restart it.
Any help would be immensely appreciated. Thank you!
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
<***@StevePiercy.com> <http://www.StevePiercy.com/>
Steve Piercy - Website Builder
2014-08-30 22:37:28 UTC
Permalink
I totally missed that in the docs. Thank you.

One more note, the directory has spaces in its name, so I used
"" around it.

[program:foo]
command=./foo
directory="/usr/local/foo foo"

Then when reloading supervisord, the program's log file has this:

supervisor: couldn't chdir to "/usr/local/foo foo": ENOENT

I also tried escaping the spaces, but with similar results.

directory=/usr/local/foo\ foo

supervisor: couldn't chdir to "/usr/local/foo foo": ENOENT

I don't think it's a permissions issue because 'foo' is the user
that owns the directory and has exec permissions.

--steve
Post by Steve Piercy - Website Builder
[program:foo]
command=./foo
directory=/usr/local/directory
<http://supervisord.org/configuration.html#program-x-section-example>
Is there any way to change the working directory in a [program:foo]
stanza?
If that ain't possible, here's the problem I am trying to solve.
The binary program "foo" lacks documentation of how to start it
directly with the secret combination of correct flipped bits and
values. There are startup shell scripts available which set the
user, umask, and some environment variables (HOME, LC_ALL,
LD_LIBRARY_PATH), but every shell script changes the working
./foo
When I try to start the binary with the fully qualified path through
[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"
foo will start, but Supervisor cannot stop or restart it.
Any help would be immensely appreciated. Thank you!
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
<***@StevePiercy.com> <http://www.StevePiercy.com/>
Steve Piercy - Website Builder
2014-08-30 23:07:52 UTC
Permalink
Yeah, I verified that it does not daemonize when I run:

sudo -u foo env
LD_LIBRARY_PATH="/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/i386:/usr/lib/jvm/jre/lib/i386/server"
./foo

I have to provide a password to issue the command, and I have to
CTL-C to exit.

--steve
Post by Aryeh Leib Taurog
You must also make sure that foo is not daemonizing itself,
or supervisor will not be able to stop or restart it.
<http://supervisord.org/subprocess.html#nondaemonizing-of-subprocesses>
Is there any way to change the working directory in a [program:foo]
stanza?
If that ain't possible, here's the problem I am trying to solve.
The binary program "foo" lacks documentation of how to start it
directly with the secret combination of correct flipped bits and
values. There are startup shell scripts available which set the
user, umask, and some environment variables (HOME, LC_ALL,
LD_LIBRARY_PATH), but every shell script changes the working
./foo
When I try to start the binary with the fully qualified path through
[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"
foo will start, but Supervisor cannot stop or restart it.
Any help would be immensely appreciated. Thank you!
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
<***@StevePiercy.com> <http://www.StevePiercy.com/>
Steve Piercy - Website Builder
2014-08-30 23:16:41 UTC
Permalink
I made a copy of the app's startup script, edited it and
commented out any stuff that requires interaction with a
password, and using your suggestion of 'exec'. Supervisor can
now start and stop the program. YAY!

Thank you for the help.

--steve
Post by Steve Piercy - Website Builder
Thanks. I tried it, but there is a problem.
sudo -u foo ./foo
sudo: sorry, you must have a tty to run sudo
I don't know how to work around that.
--steve
Steve,
You should be able to get Supervisor to manage the program ok
via a startup script as long as the script execs "foo" instead
of running it as a subprocess. Ie, the very last thing the
exec ./foo
The effect is that "foo" replaces the startup script as far as
Supervisor is concerned, so it will see SIGCHLD if "foo" exits
and a wait() will reap the exit status of "foo" itself, plus
the pid that Supervisor has will be foo's pid, so Supervisor
can send it signals.
That said, I'm on this list to learn more about Supervisor and
there may well be better ways to handle this case.
a.
Is there any way to change the working directory in a [program:foo] stanza?
If that ain't possible, here's the problem I am trying to solve.
The binary program "foo" lacks documentation of how to start it directly with the secret
combination of correct flipped bits and values. There are
startup shell scripts available which set the user, umask, and
some environment variables (HOME, LC_ALL, LD_LIBRARY_PATH),
but every shell script changes the working directory first,
./foo
[program:foo]
command=/usr/local/directory/foo
umask=002
user=foo
environment=HOME="/usr/local/directory",LC_ALL="en_US", LD_LIBRARY_PATH="baz"
foo will start, but Supervisor cannot stop or restart it.
Any help would be immensely appreciated. Thank you!
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy Website Builder Soquel, CA
<***@StevePiercy.com> <http://www.StevePiercy.com/>
Continue reading on narkive:
Loading...