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

Failing process exits process-compose immediately #1037

Open
tennox opened this issue Mar 22, 2024 · 3 comments
Open

Failing process exits process-compose immediately #1037

tennox opened this issue Mar 22, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@tennox
Copy link
Contributor

tennox commented Mar 22, 2024

If I run devenv up frontend but have a command in the exec that fails, e.g.:

processes = {
    frontend.exec = "cd page && pnpm dev --port 3000";
};

If I run this while in the subdirectory page/:

  • the command will fail because there is no such directory (that's an issue of it's own - shouldn't processed run with devenv root as PWD?)
  • process-compose will exit immediately, making it impossible to see the error message
@tennox tennox added the enhancement New feature or request label Mar 22, 2024
@tennox tennox changed the title Failing process exists process-compose immediately Failing process exits process-compose immediately Mar 22, 2024
@thenonameguy
Copy link
Contributor

the command will fail because there is no such directory (that's an issue of it's own - shouldn't processed run with devenv root as PWD?)

You can set CWD explicitly for processes, so you don't need to cd within exec:
https://github.com/schemamap/schemamap/blob/main/devenv.nix#L88-L89

process-compose will exit immediately, making it impossible to see the error message

This can be solved by setting a restart strategy, combined with the above:

processes = {
    frontend = { 
      exec = "pnpm dev --port 3000";
      process-compose = {
          working_dir = "page";
          availability.restart = "always";
      };
    };
};

@tennox
Copy link
Contributor Author

tennox commented Mar 22, 2024

Thx, this kinda works as a workaround:

frontend = {
    exec = "echo fail; false";
    process-compose = {
          availability.restart = "always";
    };
};

But I feel the default of a silent exit in case of error is a bit awkward - that's why I posted this issue 🤔

And for the working dir, while this works when I'm in the root directory:

frontend = {
      exec = "pnpm run dev";
      process-compose = {
            working_dir = "frontend";
      };
};

When I'm in the subdirectory, the command fails:

devenv up page
path '/home/manu/dev/levin-shop/frontend' does not contain a 'flake.nix', searching up

And in /tmp/process-compose-manu.log:

ERR Failed to run command exec /nix/store/r9jd1jvd9q4qxy7ilricw2g2kfm5wqlh-frontend for process frontend [0m36merror="stat frontend: no such file or directory"

@ori-nonni
Copy link

Set your working directory in the root devenv.nix and other options in sub devenv.nix. The root nix will merge the options

./devenv.nix
processes = { frontend.process-compose.working_dir = "./frontend"; };

./frontend/devenv.nix
processes = { frontend = { exec = "pnpm dev --port 3000"; process-compose = { availability.restart = "always"; }; }; };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants