Skip to content

Commit

Permalink
support systemd and others w/ pm2
Browse files Browse the repository at this point in the history
  • Loading branch information
kanreisa committed Mar 28, 2017
1 parent bdea1da commit aa83186
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app-operator.js
Expand Up @@ -66,6 +66,18 @@ const storageLowSpaceAction = config.storageLowSpaceAction || "remove"; // "none
const storageLowSpaceNotifyTo = config.storageLowSpaceNotifyTo;// e-mail address
const storageLowSpaceCommand = config.storageLowSpaceCommand || null;// command

// setuid
if (process.platform !== "win32") {
if (process.getuid() === 0) {
if (typeof config.uid === "string" || typeof config.uid === "number") {
process.setuid(config.uid);
} else {
console.error("[fatal] 'uid' required in config.");
process.exit(1);
}
}
}

// Mirakurun Client
const mirakurunPath = config.mirakurunPath || config.schedulerMirakurunPath || "http+unix://%2Fvar%2Frun%2Fmirakurun.sock/";

Expand Down
12 changes: 12 additions & 0 deletions app-wui.js
Expand Up @@ -72,6 +72,18 @@ process.on('uncaughtException', err => {
console.error('uncaughtException: ' + err);
});

// setuid
if (process.platform !== "win32") {
if (process.getuid() === 0) {
if (typeof config.uid === "string" || typeof config.uid === "number") {
process.setuid(config.uid);
} else {
console.error("[fatal] 'uid' required in config.");
process.exit(1);
}
}
}

// Mirakurun Client
const mirakurunPath = config.mirakurunPath || config.schedulerMirakurunPath || "http+unix://%2Fvar%2Frun%2Fmirakurun.sock/";

Expand Down
1 change: 1 addition & 0 deletions config.sample.json
@@ -1,4 +1,5 @@
{
"uid": null,
"mirakurunPath": "http+unix://%2Fvar%2Frun%2Fmirakurun.sock/",

"recordedDir" : "./recorded/",
Expand Down
36 changes: 36 additions & 0 deletions processes.json
@@ -0,0 +1,36 @@
{
"apps": [
{
"name": "chinachu-wui",
"script": "app-wui.js",
"node_args" : "",
"error_file": "/usr/local/var/log/chinachu-wui.stderr.log",
"out_file": "/usr/local/var/log/chinachu-wui.stdout.log",
"merge_logs": true,
"pid_file": "/usr/local/var/run/chinachu-wui.pid",
"exec_mode": "fork",
"autorestart": true,
"env": {
"NODE_ENV": "production",
"LOG_STDOUT": "/usr/local/var/log/chinachu-wui.stdout.log",
"LOG_STDERR": "/usr/local/var/log/chinachu-wui.stderr.log"
}
},
{
"name": "chinachu-operator",
"script": "app-operator.js",
"node_args" : "",
"error_file": "/usr/local/var/log/chinachu-operator.stderr.log",
"out_file": "/usr/local/var/log/chinachu-operator.stdout.log",
"merge_logs": true,
"pid_file": "/usr/local/var/run/chinachu-operator.pid",
"exec_mode": "fork",
"autorestart": true,
"env": {
"NODE_ENV": "production",
"LOG_STDOUT": "/usr/local/var/log/chinachu-operator.stdout.log",
"LOG_STDERR": "/usr/local/var/log/chinachu-operator.stderr.log"
}
}
]
}

0 comments on commit aa83186

Please sign in to comment.