Supervisor throws a permission error for npm cache when running deno commands as a non-root user
Hello, it's me, the incompetent one.
When starting a process with Supervisor under non-root privileges, you can specify it with user=, but somehow I got an error.
It seems that the cache was causing issues. When Supervisor starts a process, the environment variables remain those of the root user, so it's necessary to pass the environment variables. Since the execution command is deno, I wondered which cache it was using, and I was able to confirm it with this. It's not just ./node_modules, so when using the deno command quite a bit, my awareness of using npm assets with deno had somewhat faded.
$ npm config get cache
/home/haturatu/.npm
And these environment variables can be passed together like this:
environment=DENO_INSTALL="/home/haturatu/.deno",PATH="/home/haturatu/.deno/bin:/home/haturatu/.cargo/bin:/home/haturatu/.npm-global/bin:$PATH",HOME="/home/haturatu"
This is for deno's CMS. There's no need to pass cargo information, but I want to use this environment variable specification for other things, so I'll leave it. And it looks like this:
[program:adminblog]
command=deno task lume cms --location=http://localhost:3001
user=haturatu
directory=/var/www/html/soulmining
autostart=true ; Automatically start the process when the server boots
autorestart=true ; Automatically restart if the process terminates
stderr_logfile=/var/log/adminblog.err.log ; Location of the standard error log file
stderr_logfile_maxbytes=1MB ; Maximum file size of the log file
stdout_logfile=/var/log/adminblog.out.log ; Location of the standard output log file
stdout_logfile_maxbytes=1MB ; Maximum file size of the log file
stdout_logfile_backups=0 ; Do not keep old log files
stderr_logfile_backups=0 ; Do not keep old error output log files
environment=DENO_INSTALL="/home/haturatu/.deno",PATH="/home/haturatu/.deno/bin:/home/haturatu/.cargo/bin:/home/haturatu/.npm-global/bin:$PATH",HOME="/home/haturatu"
By the way, I feel a bit off about the directory, but it's a remnant from when I set up this server, so it can't be helped.
If I were to do it correctly, it would probably be /var/www/soulmining.
That's all for now.
See you next time.