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

Unix socket owner, not the "run-as-user" user #716

Closed
jfbelisle opened this issue Sep 17, 2014 · 8 comments
Closed

Unix socket owner, not the "run-as-user" user #716

jfbelisle opened this issue Sep 17, 2014 · 8 comments

Comments

@jfbelisle
Copy link

I manage PM2 with the root user and start my node app with the run_as_user and run_as_group flags.

So when the app is started with those flags set for a different user than root, everything is ok except that the socket created is own by root and not the specify user. This is causing me problems since i'm using Apache which is proxying the specify user to the socket but it doesn't have any rigths on it.

"apps" : [
    {
        "name"        : "otherUser",
        "cwd"         : "/home/otherUser/public_html/nodejs",
        "script"      : "app.js",
        "watch"       : "false",
        "run_as_user" : "otherUser",
        "run_as_group": "apache",
        "exec_mode"   : "cluster_mode",
        "error_file" : "./logs/child-err.log",
        "out_file"   : "./logs/child-out.log",
        "pid_file"   : "./logs/child.pid",
        "instances"   : "1",
        "env": {
            "NODE_ENV": "development"
        }
    }
]

I think to socket creation should take into account the run_as_user flag for socket creation.

@soyuka
Copy link
Collaborator

soyuka commented Sep 17, 2014

Which socket are you talking about? The apache socket that handles the proxy? That's up to you to give it the correct rights.

@jfbelisle
Copy link
Author

The unix socket that gets created by node

@soyuka
Copy link
Collaborator

soyuka commented Sep 17, 2014

Where is this socket located? Is this a pm2 unix socket?

@jfbelisle
Copy link
Author

I put all my sockets in /var/run/nodejs/sockets/

pm2 socket? They are created from my nodejs code,

var server = app.listen(config.socket, function() {...

Where config.socket is my unix socket file, /var/run/nodejs/sockets/user.sock

@soyuka
Copy link
Collaborator

soyuka commented Sep 18, 2014

That's up to you to give it the correct rights.

My advice is that pm2 and the application runs with the same user to avoid --run-as-user (#329).

@jfbelisle
Copy link
Author

I understand but what is the point of run_as_user then ?

I'm managing multiple application own by specifics users, so managing PM2 with root with run_as_user seems to logical way to go.

I need to use a script which changes the rigths on the socket after creation, the problem with this is that if PM2 restart a node app because of a crash, the app won't work because the rights on the socket are eroneous.

Do you have other ideas cause I really want to use PM2, it's so usefull.

@soyuka
Copy link
Collaborator

soyuka commented Sep 19, 2014

With the beta version it's working nice with multiple users:

You might want to test it (still beta!):
npm i pm2@rc -g

@soyuka soyuka closed this as completed Sep 19, 2014
@qfox
Copy link

qfox commented Jan 29, 2015

Still beta? ;-(

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