2

I'm now trying to deploy my Phoenix(Elixir) application in Ubuntu 16.04. For persistency, I'm using this file (app.service) in /lib/systemd/system.

[Unit]
Description=Runner for My Phoenix App

[Service]
WorkingDirectory=/app
Environment=MIX_ENV=prod PORT=4000
ExecStart=/app/bin/app start
ExecStop=/app/bin/app stop
User=mohideen
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

My username is mohideen and the account has sudo rights. When I try to use the command sudo systemctl start app.service, the command fails with the following error:

Failed to start app.service: Unknown unit: app.service
See system logs and 'systemctl status app.service' for details.

When I type sudo systemctl status app.service, I get this message:

Failed to get properties: No such interface ''

The app works fine when I start it manually. Why am I getting this error? How can I ensure that my application gets restarted on reboot and crash?

2
  • 2
    This Q is not about programming as defined for StackOverflow. It may be more appropriate on the S.E. related sites unix.stackexchange.com (Unix & Linux) or superuser.com . Use the flag link at the bottom of your Q and ask the moderator to move it. Please don't post the same Q on 2 different sites. Please read stackoverflow.com/help/how-to-ask stackoverflow.com/help/dont-ask and stackoverflow.com/help/mcve before posting more Qs here. Good luck.
    – shellter
    Mar 17, 2017 at 15:04
  • Are you sure /lib/systemd/system is the correct place to put .service files in your OS? As far as I know, in Ubuntu 16.04, they should be in /etc/systemd/system. Also try running systemctl daemon-reload before running start or status.
    – Dogbert
    Mar 17, 2017 at 15:10

1 Answer 1

4

There were two reasons for my problem.

Firstly, my .service file location was wrong. It should be /etc and not /lib.

Secondly, upstart was installed earlier by me. This prevents .service files from running (I don't know why). Once I uninstalled upstart and re-installed systemd, the problem was solved!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.