pm2 is prepending directory in Windows - pm2

I'm using pm2 to execute a process:
pm2 start "env-cmd -f ../bare-metal.env nest start --watch"
This works perfectly on Linux, however, on Windows I'm getting the following error:
[PM2][ERROR] Script not found: C:\Users\username\projectFolder\env-cmd -f ..\bare-metal.env nest start --watch
It seems like pm2 is prepending the directory. If I execute the command without pm2 it works well so the problem seems to be with pm2 on Windows.
Is it possible to fix this behavior so pm2 executes the command just as the command line does, without prepending anything?

Related

how to run pm2 with "npm run start"

So i have an app that was built for me and I need to keep it running. but the app was built with the instructions of running it with
npm run start
I am trying to figure our how to do this using either the ecosystem.config.js or command line arguments.
I tryed
pm2 start npm --name "myApp" -- run "start-test"
But the pm2 log shows an exit code of 1.
So what is the propepr way to accomplish this?

How can I get pm2 to use my ecosystem.config.js file on reboot?

My ecosystem.config.js file loads my environment great with this command:
pm2 start ecosystem.config.js
When I run any of these command, my environment is reloaded just fine:
pm2 reload myapp
pm2 restart myapp
pm2 reload ecosystem.config.js
pm2 restart ecosystem.config.js
Then I try to make sure I get my environment back after a reboot. If I run pm2 startup I get this:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u me --hp /home/me
After running that command, I can reboot my machine and my application is restarted automatically. However, I am missing my environment from the ecosystem.config.js file. Why? How do I make sure the environment from my ecosystem.config.js environment is loaded when the machine is rebooted? Thanks.
Dont forget to save your config! pm2 save
In case you want pm2 on startup with changed logs path:
pm2 delete all
pm2 start ecosystem.js
pm2 save
pm2 startup
I had the same issue. After executing the command suggested by pm2 startup, I found I had to first run pm2 delete all, then restart using pm2 start ecosystem.config.js. My environment is now loading as expected after rebooting.
May be worth sharing that a file named ecosystem.js, even if empty, needs to exist on the system in the user's home path so that pm2 can load it.

pm2 command not found after path is added

I am installing PM2 for hubot rocket.chat adapter. so i did the following:
I firstly added a file to hubot adapter folder, then
sudo npm install pm2 -g
cd <hubot directory>
pm2 start <pm2.json>
The i got error saying this:
No command 'pm2' found, did you mean:
Command 'wm2' from package 'wm2' (universe)
Command 'pms' from package 'pms' (universe)
Command 'pmk' from package 'pmk' (universe)
Command 'pmw' from package 'pmw' (universe)
Command 'fpm2' from package 'fpm2' (universe)
Command 'pom2' from package 'libpod-pom-perl' (universe)
Command 'pmi' from package 'powermanagement-interface' (universe)
Command 'pm' from package 'powerman' (universe)
pm2: command not found
Then I tried to add the path by doing:
sudo env PATH=$PATH:/home/jy/.npm-global/bin pm2 startup -u safeuser
and
export PATH=$PATH:/home/jy/.npm-global/bin
and restarted PuTTY,
still get the same error.
when I went to where PM2 is at, which is /home/jy/.npm-global/bin, and do pm2 start <pm2.json> command, still get the same error.
Is there anything i did wrong? or there might be other reasons?
The problem is that you are running NPM as sudo, so you will only be able to access it using:
sudo pm2 start server.js
Install without sudo, you may even install without the -g flag and call it directly from node_modules directory. This may be useful if you do not have root (admin) privileges in the machine you're working on.
npm install pm2
./node_modules/.bin/pm2 start server.js
Source: https://stackoverflow.com/a/40812333/1052581

Permission denied errors when creating app with custom OpenShift cartridge

I'm using OpenShift Origin and developing a cartridge for the first time. When my bin/install and bin/control scripts are running I've noticed "Permission denied" errors when they try to access anything in the cartridge usr dir. In the node platform.log I see the offending command that OpenShift runs looks like this (where my bin/control start tries to run a script in usr):
/sbin/runuser -s /bin/sh 5351e627ee5a934f290001d2 -c "exec /usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c0,c1004' /bin/sh -c \"set -e; /var/lib/openshift/5351e627ee5a934f290001d2/mycart/bin/control start \""
Since the usr dir is a symlink I originally thought it was related to that, but now I think it's related to selinux (which I don't know much about). If I do a "ls -Z" on my app's cartridge dir the files are "system_u:object_r:openshift_var_lib_t:s0:c0,c1004" but the contents of the usr dir are "unconfined_u:object_r:default_t:s0", so it doesn't match what's in the above command.
I used the oo-admin-cartridge command to install the cartridge to my Origin VM.
Any ideas on how to fix this?
What I ended up doing was running "chcon -R -u system_u -t bin_t usr/" before installing the cartridge with oo-admin-cartridge. Built-in cartridges are not affected by this problem (checked nodejs), so I feel like it might be a oo-admin-cartridge bug. I would expect it to massage the selinux permissions instead of using whatever I provide.

Error running mysql_install_db: could not find ./bin/my_print_defaults

I seem to be having an issue getting MySQL 5.6.1.5 to install from Source. I am running RHEL 6.
I was able to perform the cmake, make, and make install without issues.
I am attempting to run the mysql_install_db binary and when I do I get the following error:
Fatal ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to copy the software
into the correct location ready for operation.
If you are using a binary release, you must either bat at the top level of the
extracted archive, or pass the --basedir option pointing to that location.
So I did a check for my_print_defaults using which my_print_defaults, unfortunately it was not found on my machine.
I did a locate my_print_defaults as well just for the heck of it and said it was located in /usr/bin/my_print_defaults, however, when I checked /usr/bin for the binary, it was not actually there.
I would try to use mysql_install_db --basedir=/usr/bin but I know this won't work as the which and locate commands confirm my_print_defaults isn't on my machine.
I looked at mysql_install_db giving error, but that error was not similar to this one.
Please ignore question, I didn't bother to try running find / -name my_print_defaults and found it in /usr/local/mysql/bin/
I searched packages for my_print_defaults with
apt-file search my_print_defaults
If my_print_defaults is missing on your system (which my_print_defaults), first find out which db is installed with:
dpkg -l |grep -E 'maria|mysql'|grep ii|grep server
If you have installed mariadb, try reinstall mariadb:
sudo apt install --reinstall mariadb-server-core-10.1
If you don't find a solution with mariadb, swap back to mysql with
sudo apt install mysql-server