0

I have created a webserver using the Echo router. It act as a REST endpoint. I tried to deploy it in an Ubuntu server using systemd. The requests are getting out of memory when I try to run it as a service. However it is working fine when I run it in terminal What could be the issue.

my service file

[Unit]
Description=myapp

[Service]
Type=simple
User=root
Environment=ENV=PRODUCTION
ExecStart=/var/www/myapp/public_html/my.app
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
M14
  • 1,780
  • 2
  • 14
  • 31
  • 2
    No particular reason why this should happen. Do note you run the service as root, and when you test I assume you do it with a normal user. Check if this may have an effect on what your app does. Other than that this can't be answered without seeing your code. – icza May 25 '19 at 09:30
  • I resolved the issue by using `supervisor` instead of `systemd` – M14 May 25 '19 at 09:32
  • Also, does your app launch other processes that outlive your app? If so and your app dies often, since it is auto-restarted, those new processes might quickly grow in number... – icza May 25 '19 at 09:33
  • No this particular app does not use any other process. – M14 May 25 '19 at 09:33
  • 4
    `ExecStart=/var/www/myapp/public_html/my.app` This looks _very_ odd to me. furthermore, it is run as `root`, which is an absolute "No no" for a webserver - if someone is able to hijack the process, the attacker has root permissions. Not to mention directory traversal and other stuff that might easily happen. When using the unit, what does `systemctl status myapp` say? – Markus W Mahlberg May 25 '19 at 12:36
  • Obviously using supervisord is just a workaround, not a real solution. You probably forgot to set your `WorkingDirectory=` and some bug is causing your program to freak out because of some missing file. – Michael Hampton May 25 '19 at 17:05

0 Answers0