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

Cannot start app using /dev/snd/seq (permission denied) #3837

Closed
ghost opened this issue Aug 1, 2018 · 4 comments
Closed

Cannot start app using /dev/snd/seq (permission denied) #3837

ghost opened this issue Aug 1, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 1, 2018

What's going wrong?

An app that uses the node-midi library with ALSA (and hence opens /dev/snd/seq) fails to start under PM2 because it doesn't have permission to open /dev/snd/seq, but it works if I start the program manually. /dev/snd/seq is accessible by users in the 'audio' group, which my user is in. Shouldn't the app be able to open that path just like I can, if it's started under the same user?

How could we reproduce this issue?

Install ALSA on Ubuntu Server, make a test app using node-midi, start with pm2

Supporting information

$ pm2 report
===============================================================================
--- PM2 REPORT (Wed Aug 01 2018 11:48:27 GMT-0700 (Pacific Daylight Time)) ----
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 2.10.2
node version         : 8.11.3
node path            : undefined
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : op
uid                  : 1000
gid                  : 1000
uptime               : 5664min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 2.10.2
node version         : 10.7.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : op
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Celeron(R) CPU          420  @ 1.60GHz
cpus nb              : 1
freemem              : 116133888
totalmem             : 2079354880
home                 : /home/op
===============================================================================
--- PM2 list -----------------------------------------------
┌───────────────────────────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name                      │ id │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
├───────────────────────────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ Bitfighter Discord-IRC Bridge │ 1  │ fork │ 1142 │ online │ 0       │ 3D     │ 0%  │ 52.9 MB   │ op   │ disabled │
│ BitfighterNotifier4Discord    │ 0  │ fork │ 1137 │ online │ 0       │ 3D     │ 0%  │ 47.0 MB   │ op   │ disabled │
│ lampselfbot                   │ 2  │ fork │ 1149 │ online │ 0       │ 3D     │ 0%  │ 71.0 MB   │ op   │ disabled │
│ musicbot                      │ 3  │ fork │ 1155 │ online │ 0       │ 3D     │ 0%  │ 45.1 MB   │ op   │ disabled │
│ nmpb-mirror                   │ 5  │ fork │ 7234 │ online │ 21      │ 44h    │ 0%  │ 53.4 MB   │ op   │ disabled │
└───────────────────────────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/op/.pm2/pm2.log last 20 lines:
PM2        | [2018-08-01 11:37:58] PM2 log: App name:index id:6 online
PM2        | [2018-08-01 11:38:00] PM2 log: App [index] with id [6] and pid [637], exited with code [0] via signal [SIGABRT]
PM2        | [2018-08-01 11:38:00] PM2 log: Starting execution sequence in -fork mode- for app name:index id:6
PM2        | [2018-08-01 11:38:00] PM2 log: App name:index id:6 online
PM2        | [2018-08-01 11:38:01] PM2 log: App [index] with id [6] and pid [665], exited with code [0] via signal [SIGABRT]
PM2        | [2018-08-01 11:38:01] PM2 log: Starting execution sequence in -fork mode- for app name:index id:6
PM2        | [2018-08-01 11:38:01] PM2 log: App name:index id:6 online
PM2        | [2018-08-01 11:38:04] PM2 log: App [index] with id [6] and pid [693], exited with code [0] via signal [SIGABRT]
PM2        | [2018-08-01 11:38:04] PM2 log: Starting execution sequence in -fork mode- for app name:index id:6
PM2        | [2018-08-01 11:38:04] PM2 log: App name:index id:6 online
PM2        | [2018-08-01 11:38:05] PM2 log: App [index] with id [6] and pid [729], exited with code [0] via signal [SIGABRT]
PM2        | [2018-08-01 11:38:05] PM2 log: Starting execution sequence in -fork mode- for app name:index id:6
PM2        | [2018-08-01 11:38:05] PM2 log: App name:index id:6 online
PM2        | [2018-08-01 11:38:07] PM2 log: App [index] with id [6] and pid [758], exited with code [0] via signal [SIGABRT]
PM2        | [2018-08-01 11:38:07] PM2 log: Starting execution sequence in -fork mode- for app name:index id:6
PM2        | [2018-08-01 11:38:07] PM2 log: App name:index id:6 online
PM2        | [2018-08-01 11:38:07] PM2 log: Stopping app:index id:6
PM2        | [2018-08-01 11:38:08] PM2 log: App [index] with id [6] and pid [794], exited with code [0] via signal [SIGINT]
PM2        | [2018-08-01 11:38:08] PM2 error: Cancelling versioning data parsing
PM2        | [2018-08-01 11:38:08] PM2 log: pid=794 msg=process killed

Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues
/home/op/.pm2/logs/index-error-7.log last 15 lines:
7|index    | ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: Permission denied
7|index    | 
7|index    | MidiOutAlsa::initialize: error creating ALSA sequencer client object.
7|index    | 
7|index    | terminate called after throwing an instance of 'RtMidiError'
7|index    |   what():  MidiOutAlsa::initialize: error creating ALSA sequencer client object.

PM2        | App [index] with id [7] and pid [1867], exited with code [0] via signal [SIGABRT]
PM2        | Starting execution sequence in -fork mode- for app name:index id:7
PM2        | App name:index id:7 online
7|index    | ALSA lib seq_hw.c:466:(snd_seq_hw_open) 
7|index    | open /dev/snd/seq failed
7|index    | : Permission denied
7|index    | MidiOutAlsa::initialize: error creating ALSA sequencer client object.
7|index    | terminate called after throwing an instance of 'RtMidiError'
7|index    |   what():  MidiOutAlsa::initialize: error creating ALSA sequencer client object.
PM2        | App [index] with id [7] and pid [1905], exited with code [0] via signal [SIGABRT]
PM2        | Starting execution sequence in -fork mode- for app name:index id:7
PM2        | App name:index id:7 online
7|index    | ALSA lib seq_hw.c:466:(snd_seq_hw_open) 
7|index    | open /dev/snd/seq failed
7|index    | : Permission denied
7|index    | MidiOutAlsa::initialize: error creating ALSA sequencer client object.
7|index    | terminate called after throwing an instance of 'RtMidiError'
7|index    |   what():  MidiOutAlsa::initialize: error creating ALSA sequencer client object.
PM2        | App [index] with id [7] and pid [1933], exited with code [0] via signal [SIGABRT]
PM2        | Starting execution sequence in -fork mode- for app name:index id:7
PM2        | App name:index id:7 online
7|index    | ALSA lib seq_hw.c:466:(snd_seq_hw_open) 
7|index    | open /dev/snd/seq failed
7|index    | : Permission denied
7|index    | MidiOutAlsa::initialize: error creating ALSA sequencer client object.
7|index    | terminate called after throwing an instance of 'RtMidiError'
7|index    |   what():  MidiOutAlsa::initialize: error creating ALSA sequencer client object.
PM2        | App [index] with id [7] and pid [1961], exited with code [0] via signal [SIGABRT]
PM2        | Starting execution sequence in -fork mode- for app name:index id:7
PM2        | App name:index id:7 online
7|index    | ALSA lib seq_hw.c:466:(snd_seq_hw_open) 
7|index    | open /dev/snd/seq failed
7|index    | : Permission denied
7|index    | MidiOutAlsa::initialize: error creating ALSA sequencer client object.
7|index    | terminate called after throwing an instance of 'RtMidiError'
7|index    |   what():  MidiOutAlsa::initialize: error creating ALSA sequencer client object.
PM2        | App [index] with id [7] and pid [1989], exited with code [0] via signal [SIGABRT]
PM2        | Starting execution sequence in -fork mode- for app name:index id:7
PM2        | App name:index id:7 online
^C

@wallet77
Copy link
Contributor

wallet77 commented Aug 2, 2018

Hi @ledlamp

Nothing strange for me. If a path or an app is protected with permissions, then PM2 cli shoud have these permissions, otherwise it can't start the app.

Check PM2 group but I'm pretty sure it doesn't have the right permissions.

@ghost
Copy link
Author

ghost commented Aug 10, 2018

I don't understand; what PM2 group? There is no PM2 group in /etc/group. PM2 runs as the same user as me; shouldn't it be able to access the path?

@wallet77
Copy link
Contributor

I don't know Alsa lib, but this error is basically a rights problem and not really related to pm2.
If I try to read in a file which belong to root and if I start my script with pm2 as user, then my script will fail and I get this error :
{ Error: EACCES: permission denied, open 'file.txt' errno: -13, code: 'EACCES', syscall: 'open', path: 'file.txt' }

@ghost
Copy link
Author

ghost commented Sep 12, 2018

Turns out it is working now. I think the issue was that group changes require a re-login to take effect. I didn't know that at the time.

@ghost ghost closed this as completed Sep 12, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant