Skip to content

unable to run program with directory path #580

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

Closed
JohannesMP opened this issue Feb 16, 2015 · 6 comments
Closed

unable to run program with directory path #580

JohannesMP opened this issue Feb 16, 2015 · 6 comments

Comments

@JohannesMP
Copy link

This seems to be what #369 mentions, and #508 hopes to fix, but I was wondering if there is currently a workaround for this problem.


Basically while command=/some/path/executable works, it can break programs that try to look for files in the directory they were called from (since supervisor is technically running the executable from the root directory without cd-ing). For example I am trying to run a dedicated game server (starbound), which breaks when called in this manner since it causes it to try to find its config files in the root directory instead of the directory it is located in.

I can use

directory=/some/path
command=executable

But when I do I get an error that the says can't find command "executable", which makes sense since (as the above linked issues discuss) supervisor is not including the directory in its path.

I've been able to get around this when I'm running bash scripts like this:

directory=/some/path
command=/bin/bash script.sh

Since /bin/bash is a program in the PATH, and script.sh is being passed in as an argument. But have not been able to figure out a workaround that would let me do the same for an executable.

I realize that in regular linux you run an executable with ./executable for just this reason, since that way it looks in the current directory. However using

directory=/some/path/
command=./executable

Also seems to just give me the error can't find command './executable'. error.


Long story short, is there a workaround that I can use to make the executable run when also using the directory config option to make supervisor cd into a directory first?

I'm not terribly experienced with linux, but it seems that, in the same way that /bin/bash can be used to run bash scripts, maybe you can use another program in the PATH to execute the executable? So something like:

directory=/some/path
command=/bin/RUNEXE executable

where /bin/RUNEXE is a program in the PATH that then runs the executable as an argument?

@JohannesMP
Copy link
Author

never-mind, I figured out the workaround here:

directory=/some/path
command=/some/path/executable

you use directory to have supervisor cd first, and then still use the full path in the command. this way supervisor can find the executable, and executable does not break since supervisor first cd'd into its directory.

Oddly enough, despite similar syntax being used for other configuration options, the following:

directory=/some/path
command=%(directory)/executable

is not a valid option, which would be nice to avoid having to type out the full directory path twice

@mnaberez
Copy link
Member

I am going to close this as a duplicate of #369 or #508, both of which are related and still open.

@dvogel
Copy link

dvogel commented May 27, 2016

Another workaround:

directory=/some/absolute/path
command=sh -c 'some/relative/path/to/executable'

@lovelesh
Copy link

lovelesh commented Sep 15, 2018

@dvogel is there any workaround for c executable files.
In CLI, I am using ./path/to/executable [args]

@ghost
Copy link

ghost commented Oct 9, 2019

Another workaround:

directory=/some/absolute/path
command=sh -c 'some/relative/path/to/executable'

Thanks! it worked like a charm

@hldh214
Copy link

hldh214 commented Oct 10, 2020

Another workaround:

directory=/some/absolute/path
command=sh -c 'some/relative/path/to/executable'

Thanks, but using sh -c will cause orphan process issue when restart it w/ supervisorctl since it only "kill" the outer sh process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants