Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use npm start rather than looking for server.js #27

Open
mandric opened this issue Oct 20, 2015 · 1 comment
Open

use npm start rather than looking for server.js #27

mandric opened this issue Oct 20, 2015 · 1 comment

Comments

@mandric
Copy link
Member

mandric commented Oct 20, 2015

When launching a new package follow the standard npm config in package.json. This would allow you to easily pass arguments to the package start script without having to change anything about gardener since you can just edit your package.json.

This function could parse package.json or just call npm start. https://github.com/garden20/gardener/blob/master/lib/processes.js#L537

@mandric
Copy link
Member Author

mandric commented Oct 21, 2015

When using npm start in the forever_bind function the process detaches from forever so gardener can't manage it. Find a way to call npm start from forver without detaching the child process so when gardener stops or restarts the node module processes also die or get restarted.

This patch changes the working dir (CWD) and calls npm start with forever but is insufficient:

diff --git a/lib/processes.js b/lib/processes.js
index 6a81d5d..959891a 100644
--- a/lib/processes.js
+++ b/lib/processes.js
@@ -551,7 +551,7 @@ function start_forever(module_details, callback) {
         var working_dir = get_working_dir(module_detail),
             package_dir = get_package_dir(module_detail),
             start_script = path.resolve(get_start_script(package_dir)),
-            opts = getForeverOptions(working_dir, module_detail),
+            opts = getForeverOptions(package_dir, module_detail),
             route =  (url.parse(module_detail.ddoc_url).path),

             logname = [module_detail.db_name, utils.get_ddoc_name(module_detail.ddoc_url), module_detail.install_package.package_name].join('_'),
@@ -563,9 +563,9 @@ function start_forever(module_details, callback) {
 }

 function forever_bind(logname, start_script, opts, route) {
-    logger.info('starting [' + logname + '] with script ' + start_script);
+    logger.info('starting [' + logname + '] with npm start');

-    var child = new (forever.Monitor)(start_script, opts);
+    var child = new (forever.Monitor)(['../../../../node_modules/.bin/npm', 'start'], opts);

     child.once('error', function(err) {  process_error(logname, err);    });
     child.once('start', function(process, data) {  process_start(logname, process, data, opts);    });

See https://github.com/garden20/gardener/blob/master/lib/processes.js#L568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant