PM2 can't write to log file in cluster mode - pm2

I am converting an application to run in cluster_mode. After making the necessary additions the ecosystem.config.js file, the application fails to start due to a permission denied error:
Error: EACCES: permission denied, open '/home/node/.pm2/logs/appplication-25.log'
[2019-08-06 09:48:55] PM2 log: App name:application id:25 disconnected
[2019-08-06 09:48:55] PM2 log: App [application] with id [25] and pid [18291], exited with code [1] via signal [SIGINT]
[2019-08-06 09:48:55] PM2 log: Starting execution sequence in -cluster mode- for app name:application id:25
[2019-08-06 09:48:55] PM2 log: App name:application id:24 online
[2019-08-06 09:48:55] PM2 log: App name:application id:25 online
/usr/lib/node_modules/pm2/lib/ProcessContainer.js:202
throw err;
^
The PM2 God Daemon is running as the root user. The root user also owns the $PM2_HOME/logs directory.
$ ls -al /home/node/.pm2
total 328
drwxr-xr-x. 5 root root 199 Aug 6 09:48 .
drwxr-x---. 5 node node 66 Aug 5 15:20 ..
-rw-r--r-- 1 root root 112548 Aug 6 08:29 dump.pm2
-rw-r--r-- 1 root root 112562 Aug 2 11:43 dump.pm2.bak
drwxr-xr-x. 2 root root 32768 Aug 6 03:07 logs
-rw-r--r--. 1 root root 312 Apr 23 12:04 module_conf.json
drwxr-xr-x. 3 root root 27 Apr 23 12:04 modules
drwxr-xr-x. 2 root root 4096 Aug 6 09:48 pids
-rw-r--r--. 1 root root 51170 Aug 6 09:48 pm2.log
-rw-r--r-- 1 root root 4 Aug 5 15:19 pm2.pid
srwxrwxr-x 1 root root 0 Aug 5 15:19 pub.sock
-rw-r--r-- 1 root root 0 Aug 6 09:48 reload.lock
srwxrwxr-x 1 root root 0 Aug 5 15:19 rpc.sock
-rw-r--r--. 1 root root 13 Jul 26 2018 touch
ecosystem.config.js
module.exports = {
apps : [{
name: 'application',
script: 'index.js',
instances: 2,
exec_mode: 'cluster_mode',
}]
};
The application has been running in fork mode just fine. To test out cluster mode I ran:
pm2 delete application
pm2 start ecosystem.config.js --uid node
The result:
--- PM2 list -----------------------------------------------
┌───────────────────────────┬────┬─────────┬──────┬─────────┬─────────┬────────┬─────┬────────────┬──────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├───────────────────────────┼────┼─────────┼──────┼─────────┼─────────┼────────┼─────┼────────────┼──────┼──────────┤
│ application │ 25 │ cluster │ 0 │ errored │ 45 │ 0 │ 0% │ 0 B │ node │ disabled │
│ application │ 24 │ cluster │ 0 │ errored │ 45 │ 0 │ 0% │ 0 B │ node │ disabled │
Adding group write permissions to the logs directory, e.g. chmod 775 $PM2_HOME/logs, allows write access to the logs but I'm not sure why.
using Node.js v8.94 and PM2 v2.10.3

Related

Unable to remove a container using machinectl

I pulled a nixos container and now want to remove it.
I enter:
sudo machinectl remove nixos-21-tar
But the return message is:
Could not remove image: Access denied
If I list the images I get:
$ machinectl list-images
NAME TYPE RO USAGE CREATED MODIFIED
debian directory no n/a n/a n/a
nixos-21-tar directory no n/a n/a n/a
EDIT:
I think the image has been corrupted and the owner/group is wrong:
sudo tree /var/lib/machines/nixos-21-tar/
/var/lib/machines/nixos-21-tar/
└── var
└── empty
sudo ls -alR /var/lib/machines/nixos-21-tar/
/var/lib/machines/nixos-21-tar:
total 12
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 .
drwxrwxrwx 4 root root 4096 Apr 21 17:23 ..
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 var
/var/lib/machines/nixos-21-tar/var:
total 12
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 .
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 ..
dr-xr-xr-x 2 root root 4096 Mar 11 17:29 empty
/var/lib/machines/nixos-21-tar/var/empty:
total 8
dr-xr-xr-x 2 root root 4096 Mar 11 17:29 .
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 ..

An uncertain issue about CPU cache or GC or any else

I'm writing a arbitrary JSON parser for golang, the project nearly finished. But I found a confusing problem about the performance:
I want to test the performance about parse a big(100Mb) JSON string, I use the test file itself to init the JSON struct in memory and write the marshaled JSON string to a file, and then read from it, if the file exists already, will not init it in memory, just read from file directly. The performance is totally different: cost about double time to parse when read from file directly. At the same time, I'm testing the performance about parse normal(1Kb) JSON string and deep(2Mb) JSON string, both of these are almost unaffected.
Why? is CPU cache? or GC? or any else?
The code at https://github.com/acrazing/cheapjson, and I opened a issue about this problem at https://github.com/acrazing/cheapjson/issues/1. You can get more detailed information about the benchmark from here.
I am unable to reproduce your issue: https://github.com/acrazing/cheapjson/issues/1. My benchmark results:
$ go version
go version devel +b817359 Sat Jul 22 01:29:58 2017 +0000 linux/amd64
$ rm -rf data
$ ls -la data
ls: cannot access 'data': No such file or directory
$ go test -v -run=! -bench=. -benchmem parser_test.go
2017/07/23 02:42:09 big input size: 117265882, normal input size: 763, deep input size: 2134832
goos: linux
goarch: amd64
BenchmarkUnmarshalBigInput-4 1 1107362634 ns/op 278192256 B/op 8280859 allocs/op
BenchmarkSimpleJsonBigInput-4 1 2680878194 ns/op 569595680 B/op 7575252 allocs/op
BenchmarkUnmarshalNormalInput-4 300000 5685 ns/op 4622 B/op 129 allocs/op
BenchmarkSimpleJsonNormalInput-4 200000 9565 ns/op 5602 B/op 87 allocs/op
BenchmarkUnmarshalDeepInput-4 1000 2085186 ns/op 372922 B/op 5134 allocs/op
BenchmarkSimpleJsonDeepInput-4 100 12311435 ns/op 8911102 B/op 6117 allocs/op
PASS
ok command-line-arguments 15.067s
$ ls -la datatotal 116620
drwxr-xr-x 2 peter peter 4096 Jul 23 02:42 .
drwxr-xr-x 5 peter peter 4096 Jul 23 02:42 ..
-rwxr-xr-x 1 peter peter 117265882 Jul 23 02:42 big.json
-rwxr-xr-x 1 peter peter 2134832 Jul 23 02:42 deep.json
-rwxr-xr-x 1 peter peter 763 Jul 23 02:42 normal.json
$ go test -v -run=! -bench=. -benchmem parser_test.go
2017/07/23 02:42:31 big input size: 117265882, normal input size: 763, deep input size: 2134832
goos: linux
goarch: amd64
BenchmarkUnmarshalBigInput-4 1 1140498937 ns/op 278220704 B/op 8280995 allocs/op
BenchmarkSimpleJsonBigInput-4 1 2685285322 ns/op 569592608 B/op 7575242 allocs/op
BenchmarkUnmarshalNormalInput-4 300000 5685 ns/op 4622 B/op 129 allocs/op
BenchmarkSimpleJsonNormalInput-4 200000 9633 ns/op 5601 B/op 87 allocs/op
BenchmarkUnmarshalDeepInput-4 1000 2086891 ns/op 372927 B/op 5134 allocs/op
BenchmarkSimpleJsonDeepInput-4 100 12387413 ns/op 8911084 B/op 6117 allocs/op
PASS
ok command-line-arguments 11.903s
$ ls -la data
total 116624
drwxr-xr-x 2 peter peter 4096 Jul 23 02:42 .
drwxr-xr-x 5 peter peter 4096 Jul 23 02:42 ..
-rwxr-xr-x 1 peter peter 117265882 Jul 23 02:42 big.json
-rwxr-xr-x 1 peter peter 2134832 Jul 23 02:42 deep.json
-rwxr-xr-x 1 peter peter 763 Jul 23 02:42 normal.json
$
I got similar results on four different machines and two Operating systems: three Linux and one Windows.
This is the old benchmark result, time is at 11:01
This is the final test result currently, the result could not reproduce, it's amazing.

Recover mysql using data folder

One of our MySQL servers died but somehow we were able to recover all the files from it. This server was a slave at one time however we stopped it being a slave so we could use it for housekeeping tasks and reports, etc.
Can someone tell me how to recover with this?
I now have these files and a backup of my.cnf
ll /root/home/recovered/mysql/
-rw-r----- 1 root root 117 Jun 1 09:30 rabney-relay-bin.000001
-rw-r----- 1 root root 26 Jun 1 09:30 rabney-relay-bin.index
-rw-r----- 1 root root 113055367168 Jun 1 10:42 ibdata1
-rw-r----- 1 root root 1073741824 Jun 1 09:33 ib_logfile0
-rw-r----- 1 root root 1073741824 Jun 1 09:33 ib_logfile1
drwx------ 2 root root 4096 Jun 1 09:30 mysql
drwx------ 2 root root 16384 Jun 1 09:30 production_copy
-rw-r----- 1 root root 3253518648 Jun 1 09:32 slowquery.log
drwx------ 2 root root 4096 Jun 1 09:30 test
I've been reading articles on Google regarding this but not sure how to do it yet.

MediaWiki - Bootstrap Skin Not Rendering

I have a fresh install of MediaWiki setup. I have installed the Bootstrap Skin however it doesn't seem to be rendering anything out.
This is the path to my skins directory
/var/www/wiki/skins
Inside this I have the following
4 drwxrwxrwx 4 root root 4096 2015-07-30 15:33 CologneBlue
4 drwxrwxrwx 7 root root 4096 2015-07-31 10:36 mediawiki-bootstrap
4 drwxrwxrwx 4 root root 4096 2015-07-30 15:33 Modern
4 drwxrwxrwx 3 root root 4096 2015-07-30 15:33 MonoBook
4 -rwxrwxrwx 1 root root 1288 2015-07-30 15:33 README
4 drwxrwxrwx 6 root root 4096 2015-07-30 15:33 Vector
Inside the mediawiki-bootstap folder is the following
4 drwxrwxrwx 2 root root 4096 2015-07-31 10:36 assets
4 drwxrwxrwx 7 root root 4096 2015-07-31 10:37 bootstrap
4 -rwxrwxrwx 1 root root 524 2015-07-31 10:36 Bootstrap.i18n.php
4 -rwxrwxrwx 1 root root 2271 2015-07-31 10:36 bootstrap.php
12 -rwxrwxrwx 1 root root 9274 2015-07-31 10:36 Bootstrap.renderer.php
4 -rwxrwxrwx 1 root root 3751 2015-07-31 10:36 Bootstrap.skin.php
4 -rwxrwxrwx 1 root root 759 2015-07-31 10:36 DOMDebugPrinter.php
4 drwxrwxrwx 8 root root 4096 2015-07-31 10:37 Font-Awesome
20 -rwxrwxrwx 1 root root 18092 2015-07-31 10:36 LICENSE.txt
8 -rwxrwxrwx 1 root root 5131 2015-07-31 10:36 README.md
4 drwxrwxrwx 2 root root 4096 2015-07-31 10:36 xsl
I have added the following to my LocalSettings.php file located in the wiki folder
require_once( "/var/www/wiki/skins/mediawiki-bootstrap/bootstrap.php");
$wgDefaultSkin = "bootstrap";
#$wgDefaultSkin = "modern";
When I change back to modern, the styling and CSS loads fine. When I move to bootstrap the page loads with no styling/formatting.
I was wondering if anybody had any suggestion why this is not working for me.
Thanks

Does GT.M save database operation command in logs file

I see that have some logs file create by gt.m but just only about mupip rundown or recover information
> root#localhost:/tmp/fis-gtm/V6.2-002_x86_64# ll total 68 drwxrwxrwt 2
> root root 4096 Jul 14 16:22 ./ drwxr-xr-x 3 root root 4096 Jul 13
> 14:32 ../
> -rw-r--r-- 1 root root 0 Jul 13 14:33 root_20150713073215UTC-20150713073319UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 13 14:32 root_20150713073215UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 11:11 root_20150713073407UTC-20150714041129UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 13 14:34 root_20150713073407UTC_mupip_recover
> -rw-r--r-- 1 root root 278 Jul 14 09:46 root_20150714024647UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 09:49 root_20150714024820UTC-20150714024941UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 14 09:48 root_20150714024820UTC_mupip_recover
> -rw-r--r-- 1 root root 77 Jul 14 09:55 root_20150714025001UTC-20150714025500UTC_mupip_rundown
> -rw-r--r-- 1 root root 291 Jul 14 09:50 root_20150714025001UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 10:03 root_20150714030230UTC-20150714030331UTC_mupip_rundown
> -rw-r--r-- 1 root root 311 Jul 14 10:02 root_20150714030230UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 14:35 root_20150714030424UTC-20150714073509UTC_mupip_rundown
> -rw-r--r-- 1 root root 260 Jul 14 10:04 root_20150714030424UTC_mupip_recover
Where do I find logs about GTM command like : SET ^,WRIRE....?
Normal commands (Set, Write) are part of the core programming language and are not logged; they are journalled if they read or write something to disk. The question is what are you looking for?