Skip to content

Move the start of the server to only run when the microservice runs #73

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions helpers/mu/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ const errorHandler = function(err, req, res, next) {
});
};

// start server
app.listen( port, hostname, function() {
console.log(`Starting server on ${hostname}:${port} in ${app.get('env')} mode`);
});

export default app;

export {
Expand Down
2 changes: 1 addition & 1 deletion run-development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ cp /usr/src/app/helpers/mu/package.json /usr/src/dist/node_modules/mu/
cd /usr/src/dist/
node \
--inspect="0.0.0.0:9229" \
./app.js
./start-server.js
4 changes: 2 additions & 2 deletions run-production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ then

# boot transpiled sources
cd /usr/src/dist/
exec node ./app.js
exec node ./start-server.js
else
cd /usr/src/dist/
exec node ./app.js
exec node ./start-server.js
fi
10 changes: 10 additions & 0 deletions start-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { app } from "mu";
import "./app.js";
var port = process.env.PORT || "80";
var hostname = process.env.HOST || "0.0.0.0";
// start server
app.listen(port, hostname, function () {
console.log(
`Starting server on ${hostname}:${port} in ${app.get("env")} mode`
);
});
6 changes: 6 additions & 0 deletions transpile-sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ popd > /dev/null
## merged template and app modules with mu module
docker-rsync --delete /usr/src/app/app/node_modules /usr/src/dist/
docker-rsync /usr/src/app/app/package.json /usr/src/dist/package.json


#########################
# Add server start script
#########################
cp /usr/src/app/start-server.js /usr/src/dist/start-server.js