1

So I'm really new into loading the node server on AWS, basically I followed some guide to start node from etc/init

so I have a file like that in etc/init

menuserver.conf

#!upstart
description "menu-creator server"

start on started mountall
stop on shutdown

# Automatically Respawn:
respawn
respawn limit 99 5

env NODE_ENV=development

# Warning: this runs node as root user, which is a security risk
# in many scenarios, but upstart-ing a process as a non-root user
# is outside the scope of this question
exec node /home/ec2-user/MenuCreator/app.js >> /var/log/yourappname.log 2>&1

I have updated the server code, and wish to restart the server, how to do it? as I'm just starting out, I don't care so much for the security risks.

I've tried etc/init.d/menuserver restart, but actually menuserver isn't found in init.d.

looking for a quick way to restart the program, and also for a long term good practice guide for how to setup and restart the server. (I think I heard Forever is recommended... is it?)

Yaniv Peretz
  • 1,118
  • 2
  • 13
  • 22
  • Have you tried this ? https://stackoverflow.com/a/29042953/4896841 – Taknok Jan 20 '18 at 13:25
  • I'm kinda lost on what is the right way into doing this, but for now I've succeeded to stop the service. I will go thorough th link – Yaniv Peretz Jan 20 '18 at 14:01
  • If you're using upstart for task management then you should read the upstart documentation. It will tell you how to stop/start tasks. – jarmod Jan 20 '18 at 18:29

2 Answers2

2

Try setting pm2 on server. You can easily restart server then. Study more about pm2 http://pm2.keymetrics.io/

Saurabh Arora
  • 431
  • 3
  • 11
0

sudo stop/start/restart service name worked for me, example:

sudo stop menuserver

Yaniv Peretz
  • 1,118
  • 2
  • 13
  • 22