Skip to content

Commit 11052aa

Browse files
committed
process start fix
1 parent 6ebe986 commit 11052aa

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

mailcatcher.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ public function setup( $user, $domain ) {
7171
}
7272

7373
// Start mailcatcher if not started
74-
if ( !is_dir('/home/mailcatcher/.pm2') ) {
75-
$cmd = 'runuser -l mailcatcher -c "cd /opt/mailcatcher && source /opt/nvm/nvm.sh ; pm2 start mailcatcher.config.js"';
76-
shell_exec( $cmd );
77-
}
74+
$cmd = 'if ! runuser -l "mailcatcher" -c "cd /opt/mailcatcher && source /opt/nvm/nvm.sh && pm2 list" | grep -q "mailcatcher_app"; ';
75+
$cmd .= 'then runuser -l "mailcatcher" -c "cd /opt/mailcatcher && source /opt/nvm/nvm.sh ; pm2 start mailcatcher.config.js"; fi';
76+
shell_exec( $cmd );
7877
}
7978

8079
public function priv_unsuspend_domain( $args ) {

src/mailcatcher.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ module.exports = {
33

44
// Obtain mailcatcher details
55
const fs = require('fs');
6-
const {execSync} = require('child_process');
7-
let hostname = execSync('/bin/bash -c "hostname -f"').toString().trim();
8-
hostname = hostname.split('.').slice(-2).join('.');
96
let details = {};
107
details.cwd = '/opt/mailcatcher';
118
details._app = 'mailcatcher';
12-
details.name = details._app + '-' + hostname;
9+
details.name = details._app + '_app';
1310
details.script = details.cwd + '/' + details._app + '.js';
1411
details.watch = ['.restart'];
1512
details.ignore_watch = [];
@@ -22,6 +19,7 @@ module.exports = {
2219
if (fs.existsSync(nvmrc)) {
2320
ver = fs.readFileSync(nvmrc, {encoding: 'utf8', flat: 'r'}).trim();
2421
}
22+
const {execSync} = require('child_process');
2523
ver = execSync('/bin/bash -c "source /opt/nvm/nvm.sh && nvm which ' + ver + '"').toString().trim();
2624
if (!fs.existsSync(ver)) {
2725
console.error(ver);

0 commit comments

Comments
 (0)