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

@resurrect-processes does not work with npm start #201

Closed
bassamseif opened this issue Jul 7, 2017 · 5 comments
Closed

@resurrect-processes does not work with npm start #201

bassamseif opened this issue Jul 7, 2017 · 5 comments

Comments

@bassamseif
Copy link

I have checked ~/.tmux/resurrect/last apparently npm start is being saved as :npm rather than :npm start
Added it manually and tried restoring it works, so the saving mechanism needs fixing

@bruno-
Copy link
Member

bruno- commented Jul 8, 2017

There have been reports of wrongly saved process names for some javascript tools (grunt or gulp, don't remember now). Also, I just checked and I get the same for npm run start (the saved process name is just npm).

I think the issue here is the tool (npm) doesn't set the proper process name with all the arguments etc. And that's super easy to do, check this!

Here's the fastest way to set a node process name:

$ node   # start node repl
> process.title = 'foo bar baz'

Now ps -ef | grep foo will show foo bar baz on a list of processes.

Anyway, I'd suggest contributing to npm as a proper solution for this one.

@bruno- bruno- closed this as completed Jul 8, 2017
@unphased
Copy link

unphased commented Oct 8, 2020

Thanks for the breadcrumbs @bruno-

This seems still to be an issue as I see my npm processes saved as :npm in the file, so it's kind of a problem.

I am thinking that if we inject the process.title setting from our application then it would be able to connect to a -> process resurrection rule, right? e.g. we set process.title in our app to something really rather specific, and then the process resurrection rule can key off of that.

@unphased
Copy link

unphased commented Oct 8, 2020

This doesn't work. See this process structure:

├─ -zsh
│  ├─ -zsh
│  └─ npm
│     └─ sh -c PORT=3001 node scripts/start.js
│        └─ Custom process title
│           └─ /opt/nodejs/node-v12.18.3-linux-x64/bin/node --max-old-space-size=2048 /home/user/application/client/node_modules/react-dev-utils/node_modules/fork-ts-checker-webpack-plugin/lib/service.js

:( Still persisted in resurrect as npm.

@bruno-
Copy link
Member

bruno- commented Oct 9, 2020

Other people have solved this, check the docs https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/restoring_programs.md#nodejs

@unphased
Copy link

unphased commented Oct 9, 2020

Yep I have looked at that section. I don't wanna come across the wrong way, but... yarn isn't npm. Some people may be able to switch to yarn, but it's sort of silly to assume everyone can. But I mostly understand the problem with npm at this point. It's with the code. I did make a PR there (you can see linked above).

One thing I def wanted to swing back to mention is that a quick way to work around all of this silliness is to just make your own shell wrapper script to run.

For example two of the npm processes I need are npm start in src/client and npm start in src/server. Resurrect already restores the cwd, so all I needed to do was to execute a script of mine named npm-start, the script is literally a bash script that executes npm start. Voila and I have all 4 of these processes restored by resurrect. Perfect!

isaacs added a commit to npm/cli that referenced this issue Nov 10, 2020
This includes all positional args (ie, not anything that is a config),
except for the third positional arg when running `npm token revoke ...`,
since that is also a secret.

Makes the `ps` entry a bit more useful than just "npm", so users can at
least get some clue what npm is doing, while minimizing the degree to
which we leak anything secret.

Closes: #1927
Fixes: https://npm.community/t/8400
Related: tmux-plugins/tmux-resurrect#201
darcyclarke pushed a commit to npm/cli that referenced this issue Nov 13, 2020
This includes all positional args (ie, not anything that is a config),
except for the third positional arg when running `npm token revoke ...`,
since that is also a secret.

Makes the `ps` entry a bit more useful than just "npm", so users can at
least get some clue what npm is doing, while minimizing the degree to
which we leak anything secret.

Closes: #1927
Fixes: https://npm.community/t/8400
Related: tmux-plugins/tmux-resurrect#201

Credit: @isaacs
Close: #2154
Reviewed-by: @ruyadorno
isaacs added a commit to npm/cli that referenced this issue Nov 13, 2020
This includes all positional args (ie, not anything that is a config),
except for the third positional arg when running `npm token revoke ...`,
since that is also a secret.

Makes the `ps` entry a bit more useful than just "npm", so users can at
least get some clue what npm is doing, while minimizing the degree to
which we leak anything secret.

Closes: #1927
Fixes: https://npm.community/t/8400
Related: tmux-plugins/tmux-resurrect#201

Credit: @isaacs
Close: #2154
Reviewed-by: @ruyadorno
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

3 participants