Need to run a NodeJs application from another NodeJs application
I have a NodeJs application running in the following directory
First Application's Path '/users/user1/projects/sampleProject' which is running at 3000 port.
Second Application's Path '/users/user1/demoProjects/demo1' which is going to run at 5000 port on triggering the router function from first application.
The second NodeJs application is not yet started(It will run at port 5000). It need to run independently on hitting a router function in the first NodeJs Application which is running on port 3000 ie(http://localhost:3000/server/startServer). I'm new to NodeJs child processes, Kindly correct me if i'm wrong. And suggest me a right way to do it. Thanks
Start another node application using node.js?
I have tried it like below
// First NodeJs application
import { exec } from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function (err, stdout, stderr) {
if (err) throw err;
else {
console.log("result ")
res.json({
status: 'success'
});
}
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
The above code executes the command and triggered the second application to run in background but it doesn't return anything. Either error or success result.
node.js child-process
|
show 9 more comments
I have a NodeJs application running in the following directory
First Application's Path '/users/user1/projects/sampleProject' which is running at 3000 port.
Second Application's Path '/users/user1/demoProjects/demo1' which is going to run at 5000 port on triggering the router function from first application.
The second NodeJs application is not yet started(It will run at port 5000). It need to run independently on hitting a router function in the first NodeJs Application which is running on port 3000 ie(http://localhost:3000/server/startServer). I'm new to NodeJs child processes, Kindly correct me if i'm wrong. And suggest me a right way to do it. Thanks
Start another node application using node.js?
I have tried it like below
// First NodeJs application
import { exec } from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function (err, stdout, stderr) {
if (err) throw err;
else {
console.log("result ")
res.json({
status: 'success'
});
}
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
The above code executes the command and triggered the second application to run in background but it doesn't return anything. Either error or success result.
node.js child-process
Can you provide a bit more detail about why you want to do this? It seems rather unorthodox. See also What is the X Y problem?
– Robert Harvey♦
Jan 18 at 15:24
Also, you can'tawaita function that will return a result into a callback (well, you can, but it wouldn't work as you expects)
– RidgeA
Jan 18 at 15:30
which version of node do you are using?
– Manuel Spigolon
Jan 18 at 15:32
@Manuel Spigolon, node - 8.10.0, npm - 5.6.0
– Jeeva
Jan 18 at 15:33
1
The callback function is only called once the process terminates. If your child process remains running the callback is not triggered.
– KVNam
Jan 18 at 15:42
|
show 9 more comments
I have a NodeJs application running in the following directory
First Application's Path '/users/user1/projects/sampleProject' which is running at 3000 port.
Second Application's Path '/users/user1/demoProjects/demo1' which is going to run at 5000 port on triggering the router function from first application.
The second NodeJs application is not yet started(It will run at port 5000). It need to run independently on hitting a router function in the first NodeJs Application which is running on port 3000 ie(http://localhost:3000/server/startServer). I'm new to NodeJs child processes, Kindly correct me if i'm wrong. And suggest me a right way to do it. Thanks
Start another node application using node.js?
I have tried it like below
// First NodeJs application
import { exec } from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function (err, stdout, stderr) {
if (err) throw err;
else {
console.log("result ")
res.json({
status: 'success'
});
}
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
The above code executes the command and triggered the second application to run in background but it doesn't return anything. Either error or success result.
node.js child-process
I have a NodeJs application running in the following directory
First Application's Path '/users/user1/projects/sampleProject' which is running at 3000 port.
Second Application's Path '/users/user1/demoProjects/demo1' which is going to run at 5000 port on triggering the router function from first application.
The second NodeJs application is not yet started(It will run at port 5000). It need to run independently on hitting a router function in the first NodeJs Application which is running on port 3000 ie(http://localhost:3000/server/startServer). I'm new to NodeJs child processes, Kindly correct me if i'm wrong. And suggest me a right way to do it. Thanks
Start another node application using node.js?
I have tried it like below
// First NodeJs application
import { exec } from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function (err, stdout, stderr) {
if (err) throw err;
else {
console.log("result ")
res.json({
status: 'success'
});
}
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
The above code executes the command and triggered the second application to run in background but it doesn't return anything. Either error or success result.
node.js child-process
node.js child-process
edited Jan 18 at 15:31
Jeeva
asked Jan 18 at 15:22
JeevaJeeva
63439
63439
Can you provide a bit more detail about why you want to do this? It seems rather unorthodox. See also What is the X Y problem?
– Robert Harvey♦
Jan 18 at 15:24
Also, you can'tawaita function that will return a result into a callback (well, you can, but it wouldn't work as you expects)
– RidgeA
Jan 18 at 15:30
which version of node do you are using?
– Manuel Spigolon
Jan 18 at 15:32
@Manuel Spigolon, node - 8.10.0, npm - 5.6.0
– Jeeva
Jan 18 at 15:33
1
The callback function is only called once the process terminates. If your child process remains running the callback is not triggered.
– KVNam
Jan 18 at 15:42
|
show 9 more comments
Can you provide a bit more detail about why you want to do this? It seems rather unorthodox. See also What is the X Y problem?
– Robert Harvey♦
Jan 18 at 15:24
Also, you can'tawaita function that will return a result into a callback (well, you can, but it wouldn't work as you expects)
– RidgeA
Jan 18 at 15:30
which version of node do you are using?
– Manuel Spigolon
Jan 18 at 15:32
@Manuel Spigolon, node - 8.10.0, npm - 5.6.0
– Jeeva
Jan 18 at 15:33
1
The callback function is only called once the process terminates. If your child process remains running the callback is not triggered.
– KVNam
Jan 18 at 15:42
Can you provide a bit more detail about why you want to do this? It seems rather unorthodox. See also What is the X Y problem?
– Robert Harvey♦
Jan 18 at 15:24
Can you provide a bit more detail about why you want to do this? It seems rather unorthodox. See also What is the X Y problem?
– Robert Harvey♦
Jan 18 at 15:24
Also, you can't
await a function that will return a result into a callback (well, you can, but it wouldn't work as you expects)– RidgeA
Jan 18 at 15:30
Also, you can't
await a function that will return a result into a callback (well, you can, but it wouldn't work as you expects)– RidgeA
Jan 18 at 15:30
which version of node do you are using?
– Manuel Spigolon
Jan 18 at 15:32
which version of node do you are using?
– Manuel Spigolon
Jan 18 at 15:32
@Manuel Spigolon, node - 8.10.0, npm - 5.6.0
– Jeeva
Jan 18 at 15:33
@Manuel Spigolon, node - 8.10.0, npm - 5.6.0
– Jeeva
Jan 18 at 15:33
1
1
The callback function is only called once the process terminates. If your child process remains running the callback is not triggered.
– KVNam
Jan 18 at 15:42
The callback function is only called once the process terminates. If your child process remains running the callback is not triggered.
– KVNam
Jan 18 at 15:42
|
show 9 more comments
2 Answers
2
active
oldest
votes
You need to use stout and stderror to check other server logs. Also your code is not correct. If you use if without {} it will not go to else statement. That is why you don't see 'result' text in console.
import {
exec
} from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function(err) {
if (err) throw err;
console.log("Server started");
});
child.stdout.on('data', (data) => {
// this is new server output
console.log(data.toString());
});
child.stderr.on('data', (data) => {
// this is new server error output
console.log(data.toString());
});
res.json({
status: 'success'
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
How is this working for you? I thoughtstdoutandstderrare of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.
– KVNam
Jan 18 at 15:51
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
add a comment |
Child process callback is only called once the process terminates. If the process keeps running, callback is not triggered.
Explained here - https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_child_process_exec_command_options_callback
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
1
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. Thechildvariable which holds the ChildProcess instance, can be used to watch fordataevents. This is outside the callback so you don't have to wait for the process to terminate. There is amessageevent as well which you can check out.
– KVNam
Jan 18 at 17:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54256871%2fneed-to-run-a-nodejs-application-from-another-nodejs-application%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to use stout and stderror to check other server logs. Also your code is not correct. If you use if without {} it will not go to else statement. That is why you don't see 'result' text in console.
import {
exec
} from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function(err) {
if (err) throw err;
console.log("Server started");
});
child.stdout.on('data', (data) => {
// this is new server output
console.log(data.toString());
});
child.stderr.on('data', (data) => {
// this is new server error output
console.log(data.toString());
});
res.json({
status: 'success'
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
How is this working for you? I thoughtstdoutandstderrare of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.
– KVNam
Jan 18 at 15:51
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
add a comment |
You need to use stout and stderror to check other server logs. Also your code is not correct. If you use if without {} it will not go to else statement. That is why you don't see 'result' text in console.
import {
exec
} from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function(err) {
if (err) throw err;
console.log("Server started");
});
child.stdout.on('data', (data) => {
// this is new server output
console.log(data.toString());
});
child.stderr.on('data', (data) => {
// this is new server error output
console.log(data.toString());
});
res.json({
status: 'success'
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
How is this working for you? I thoughtstdoutandstderrare of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.
– KVNam
Jan 18 at 15:51
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
add a comment |
You need to use stout and stderror to check other server logs. Also your code is not correct. If you use if without {} it will not go to else statement. That is why you don't see 'result' text in console.
import {
exec
} from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function(err) {
if (err) throw err;
console.log("Server started");
});
child.stdout.on('data', (data) => {
// this is new server output
console.log(data.toString());
});
child.stderr.on('data', (data) => {
// this is new server error output
console.log(data.toString());
});
res.json({
status: 'success'
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
You need to use stout and stderror to check other server logs. Also your code is not correct. If you use if without {} it will not go to else statement. That is why you don't see 'result' text in console.
import {
exec
} from "child_process";
router.get('/startServer', async (req, res, next) => {
console.log("Initiated request")
let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; // path for the second NodeJs application
console.log("Server instance path => " + startServerInstance)
try {
// exec from child process, Spawns a shell then executes the command within that shell
let child = exec(startServerInstance, function(err) {
if (err) throw err;
console.log("Server started");
});
child.stdout.on('data', (data) => {
// this is new server output
console.log(data.toString());
});
child.stderr.on('data', (data) => {
// this is new server error output
console.log(data.toString());
});
res.json({
status: 'success'
});
} catch (error) {
res.json({
status: 'error',
message: error
});
}
});
edited Jan 18 at 16:13
answered Jan 18 at 15:44
hurricanehurricane
3,75011934
3,75011934
How is this working for you? I thoughtstdoutandstderrare of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.
– KVNam
Jan 18 at 15:51
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
add a comment |
How is this working for you? I thoughtstdoutandstderrare of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.
– KVNam
Jan 18 at 15:51
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
How is this working for you? I thought
stdout and stderr are of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.– KVNam
Jan 18 at 15:51
How is this working for you? I thought
stdout and stderr are of either string or buffer type, containing the output from the child process and not in fact pipes. I'm getting an error when I try this.– KVNam
Jan 18 at 15:51
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
You are right. I have changed it.
– hurricane
Jan 18 at 16:13
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
@hurricane, Thank you for your answer, Now I can able to see the data events
– Jeeva
Jan 19 at 5:32
add a comment |
Child process callback is only called once the process terminates. If the process keeps running, callback is not triggered.
Explained here - https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_child_process_exec_command_options_callback
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
1
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. Thechildvariable which holds the ChildProcess instance, can be used to watch fordataevents. This is outside the callback so you don't have to wait for the process to terminate. There is amessageevent as well which you can check out.
– KVNam
Jan 18 at 17:56
add a comment |
Child process callback is only called once the process terminates. If the process keeps running, callback is not triggered.
Explained here - https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_child_process_exec_command_options_callback
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
1
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. Thechildvariable which holds the ChildProcess instance, can be used to watch fordataevents. This is outside the callback so you don't have to wait for the process to terminate. There is amessageevent as well which you can check out.
– KVNam
Jan 18 at 17:56
add a comment |
Child process callback is only called once the process terminates. If the process keeps running, callback is not triggered.
Explained here - https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_child_process_exec_command_options_callback
Child process callback is only called once the process terminates. If the process keeps running, callback is not triggered.
Explained here - https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_child_process_exec_command_options_callback
answered Jan 18 at 15:59
KVNamKVNam
6191120
6191120
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
1
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. Thechildvariable which holds the ChildProcess instance, can be used to watch fordataevents. This is outside the callback so you don't have to wait for the process to terminate. There is amessageevent as well which you can check out.
– KVNam
Jan 18 at 17:56
add a comment |
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
1
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. Thechildvariable which holds the ChildProcess instance, can be used to watch fordataevents. This is outside the callback so you don't have to wait for the process to terminate. There is amessageevent as well which you can check out.
– KVNam
Jan 18 at 17:56
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
Hi KVNam, I have tried the below scenario. The callback is called once the process terminates. eg. replaced the let startServerInstance = 'cd "/users/user1/demoProjects/demo1" && npm run dev'; with let startServerInstance = 'mkdir -p ./testDir'. It had created the folder. Hence the process is completed and i got the response. But in my case, its an ever running process. so i manually killed the port after it ran. By this time it might have fired the callback so the process is complete by killing it, but i didnt get any response
– Jeeva
Jan 18 at 16:33
1
1
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. The
child variable which holds the ChildProcess instance, can be used to watch for data events. This is outside the callback so you don't have to wait for the process to terminate. There is a message event as well which you can check out.– KVNam
Jan 18 at 17:56
The corrected answer given by @hurricane below is the right way to capture stdout data from a running process. The
child variable which holds the ChildProcess instance, can be used to watch for data events. This is outside the callback so you don't have to wait for the process to terminate. There is a message event as well which you can check out.– KVNam
Jan 18 at 17:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54256871%2fneed-to-run-a-nodejs-application-from-another-nodejs-application%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you provide a bit more detail about why you want to do this? It seems rather unorthodox. See also What is the X Y problem?
– Robert Harvey♦
Jan 18 at 15:24
Also, you can't
awaita function that will return a result into a callback (well, you can, but it wouldn't work as you expects)– RidgeA
Jan 18 at 15:30
which version of node do you are using?
– Manuel Spigolon
Jan 18 at 15:32
@Manuel Spigolon, node - 8.10.0, npm - 5.6.0
– Jeeva
Jan 18 at 15:33
1
The callback function is only called once the process terminates. If your child process remains running the callback is not triggered.
– KVNam
Jan 18 at 15:42