Error starting systemd service

systemd

#1

I want to run my application as a service which starts on boot and always restarts if it exists for any reason.

To do this I’m trying to create and run a systemd service. However, I get an error when I manually trying to run systemctl start /etc/systemd/system/my_service.service saying Failed to start etc-systemd-system-ccon\x2dism\x2dcloud.service.mount: Unit etc-systemd-system-ccon\x2dism\x2dcloud.service.mount failed to load: No such file or directory.

The content of the my_service.service file is:

[Unit]
Description=Main Application Service

[Service]
EnvironmentFile=/etc/docker.env
Type=simple
ExecStart=/app/my-binary
Restart=always

[Install]
WantedBy=multi-user.target

My dockerfile:

FROM resin/armv7hf-debian

# Copy repository content recursively to the 'app' folder
COPY . /app

# Switch on systemd init system in container and add the ccon-ism-cloud service
ENV INITSYSTEM on
COPY my_service.service /etc/systemd/system/my_service.service
RUN systemctl enable /etc/systemd/system/my_service.service

CMD /bin/bash

#3

:speech_balloon:I’ve not had any experience as a service, and can ask around, but I do have experience of my applications aborting and (from memory, don’t happen to have a project in this state at the moment) the docker container restarts once execution ends.


#4

Did this solution work for you? If not I will ask around, but am hopeful that the simpler solution might work for you.


#5

I’ve used these lines differently:

COPY my_service.service /lib/systemd/system/
RUN systemctl enable my_service

I’ve created a small service like that for testing (running a short ping on boot), and works like a charm, runs on start just fine.

Also, since it’s unclear why the etc-systemd-system-ccon\x2dism\x2dcloud.service.mount is mentioned by systemd, I did a quick scan, don’t see that in the resin.io side.

What resinOS version are you using? Is it possible to share a link to your whole project to get some more idea what might be going wrong?


#7

Thanks @imrehg, that worked for me!