Keywords: MEAN - Google Cloud Platform - How to - Other
Description:
Hi,
I had installed mean stack, added couple of thing and not I want to disable apache to run on startup. I had created 2 scripts.
myapp.service
[Unit]
Description=pm2 app autostart
After=network.target
[Service]
ExecStart=/home/me/app/startup.sh start
ExecStop=/home/me/app/startup.sh stop
Restart=always
[Install]
WantedBy=multi-user.target
which I added to systemd to run on startup. And the second script startup.sh:
#!/bin/bash
case "$1" in
start)
/opt/bitnami/ctlscript.sh stop apache
/opt/bitnami/nodejs/bin/pm2 start /home/mee/app/app2.json
;;
stop)
/opt/bitnami/nodejs/bin/pm2 stop all
;;
restart)
/opt/bitnami/nodejs/bin/pm2 restart all
;;
esac
exit $?
So the script should stop just apache ( and I can see in systemd logs that indeed it is not running). Then it should start pm2 conf.json with my app and occupy port 80 before apache starts/restart ( at least thats my idea).
But I keep failing to produce this result. I can see that my scripts were running but at the end of logs pm2 instance is shut down and httpd.bin is spawned...
Any suggestions?