Can not start service

Hello.
Please help understand why it’s not impossible to start the service

apps:
    veeamservice:
        command: usr/sbin/veeamservice --start
        stop-command: usr/sbin/veeamservice --stop
        stop-timeout: 5s
        daemon: simple
        plugs: [home, gsettings, raw-usb, serial-port, network]


sudo systemctl start snap.veeam.veeamservice.service
sudo systemctl status snap.veeam.veeamservice.service
● snap.veeam.veeamservice.service - Service for snap application veeam.veeamservice
   Loaded: loaded (/etc/systemd/system/snap.veeam.veeamservice.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since St 2018-08-29 22:06:59 CEST; 12s ago
  Process: 18969 ExecStop=/usr/bin/snap run --command=stop veeam.veeamservice (code=exited, status=1/FAILURE)
  Process: 18958 ExecStart=/usr/bin/snap run veeam.veeamservice (code=exited, status=1/FAILURE)
 Main PID: 18958 (code=exited, status=1/FAILURE)

srp 29 22:06:59 blin-KDENeon systemd[1]: snap.veeam.veeamservice.service: Unit entered failed state.
srp 29 22:06:59 blin-KDENeon systemd[1]: snap.veeam.veeamservice.service: Failed with result 'exit-code'.
srp 29 22:06:59 blin-KDENeon systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
srp 29 22:06:59 blin-KDENeon systemd[1]: Stopped Service for snap application veeam.veeamservice.
srp 29 22:06:59 blin-KDENeon systemd[1]: snap.veeam.veeamservice.service: Start request repeated too quickly.
srp 29 22:06:59 blin-KDENeon systemd[1]: Failed to start Service for snap application veeam.veeamservice.

Maybe something else is missing?
Thx.

does your service fork? If it does then you need to either find a way for it to not fork or change your configuration to daemon: forking and hope that it works correctly (I’ve seen anecdotal evidence that there may be problems with forking services, but that’s hearsay).

What is mean “service fork”?
I tried what you advised, but it’s not help, error

error: cannot perform the following tasks:
- Start snap "veeam" (unset) services ([start snap.veeam.veeamservice.service] failed with exit status 1: Job for snap.veeam.veeamservice.service failed because the control process exited with error code. See "systemctl status snap.veeam.veeamservice.service" and "journalctl -xe" for details.
)

command result “journalctl -xe”
done.
srp 29 22:38:46 blin-KDENeon sudo[6067]: blin : TTY=pts/0 ; PWD=/media/free/SNAP/Veeam ; USER=root ; COMMAND=/bin/systemctl status snap.veeam.veeamservice.service
srp 29 22:38:46 blin-KDENeon sudo[6067]: pam_unix(sudo:session): session opened for user root by blin(uid=0)
srp 29 22:38:46 blin-KDENeon sudo[6067]: pam_unix(sudo:session): session closed for user root
srp 29 22:38:56 blin-KDENeon sudo[6071]: blin : TTY=pts/0 ; PWD=/media/free/SNAP/Veeam ; USER=root ; COMMAND=/bin/systemctl start snap.veeam.veeamservice.service
srp 29 22:38:56 blin-KDENeon sudo[6071]: pam_unix(sudo:session): session opened for user root by blin(uid=0)
srp 29 22:38:56 blin-KDENeon sudo[6071]: pam_unix(sudo:session): session closed for user root
srp 29 22:45:10 blin-KDENeon sudo[6140]: blin : TTY=pts/0 ; PWD=/media/free/SNAP/Veeam ; USER=root ; COMMAND=/bin/systemctl start snap.veeam.veeamservice.service
srp 29 22:45:10 blin-KDENeon sudo[6140]: pam_unix(sudo:session): session opened for user root by blin(uid=0)
srp 29 22:45:10 blin-KDENeon sudo[6140]: pam_unix(sudo:session): session closed for user root

How else can you understand what the problem is?

@mvo is it already possible to shell into the environment of a service?

are you sure you actually need --start and the stop-command line in your definition at all ?

i’d try to drop both for a test and leave all of the management to systemd here.

Most likely I still do not understand how the service works in a snap, but I need to start and stop the service as it is.
Is there another way?
This service is needed for work main program.

it works like any other systemd service, during install snapd creates a service unit for systemd based on teh info you give in snapcraft.yaml …

you can inspect all these unit files for installed snaps with:

ls /etc/systemd/system/*service|grep snap\\.

often the --start and --stop calls are not necessarily needed when you let systemd do the handling, but if you tried and it does not work (because it is originally a sysvinit script or does some other special setup/teardown things due to the options) then … well … it was at least worth a try …

@ogra
When I start the service in normal mode without snap, I do
sudo service veeamservice start
And now I found in /etc/init.d file veeamservice
I have now found in description that the service starts as initd.
How in this case it is necessary to launch service in a snap?
Thx.

if this works, i do not understand why it did not work when you removed --start from your command:

you should try to find the .service file the above command invokes and look at what exactly it executes, then put that into your command:

Hi.
This is what the file looks like, which is located the way /etc/init.d/veeamservice

# Author: Veeam Software AG <https://www.veeam.com/contacts.html>
# Do NOT "set -e"

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Veeam Agent for Linux service"
NAME=veeamservice
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="--daemonize --pidfile=$PIDFILE"
SCRIPTNAME=/etc/init.d/$NAME
MODULE_NAME="veeamsnap"

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}

What should I do? To re-create the script so that it runs the service as a systemd or it is necessary in snapcraft.yaml what to write for the correct start, and run without a script?

that obviously execs:

usr/sbin/veeamservice --daemonize

not using --start at all …

so try that in your command (and drop the stop-command: systemd should take care)

--daemonize to me says that it’ll do a fork.

Try removing it entirely, just running usr/sbin/veeamservice, with daemon: simple. If you need to keep --daemonize you almost certainly need daemon: forking (but that’s more brittle).

I correctly understand that I do not need to rewrite the script under systemd, but just do it with the key (–daemonize) as you wrote it?

this is what i asked for in my very first relply and @sektorct said it did not work :confused:

This option also did not give a positive result.
Also, the service does not start.
I do not understand what is wrong (

just to make sure, if you try the thing i asked for in my very first comment in this thread, it does definitely not work ?

apps:
    veeamservice:
        command: usr/sbin/veeamservice
        daemon: simple
        plugs: [home, gsettings, raw-usb, serial-port, network]

also: did you connect all the interfaces you defined in the plugs section ? not all of them do auto-connect, you will need to manually use snap connect to connect them … specifically serial-port and raw-usb (and for serial-port you will likely need some other snap to actually provide that interface)

@ogra
snapcraft.yaml looks like this

name: veeam
version: "0.1.0"
summary: backup
description: |
    Application for backup system
confinement: strict
architectures: [amd64]

apps:
    veeam:
        command: usr/bin/veeam
        plugs: [home]
    veeamconfig:
        command: usr/bin/veeamconfig
        plugs: [home, network]
    veeamagent:
        command: usr/sbin/veeamagent
        plugs: [home]
    veeamservice:
        command: usr/sbin/veeamservice
        daemon: simple
        plugs: [home, network]
parts:
    veeam:
        plugin: dump
        source: scripts
        source-type: local
        build-attributes: [keep-execstack]

    integration:
        plugin: nil
        stage-packages:
            - libc-bin
            - libc6
            - libclutter-1.0-0
            - libxkbcommon0
            - ttf-ubuntu-font-family
            - dmz-cursor-theme
            - libglib2.0-0
            - light-themes
            - shared-mime-info
            - libgdk-pixbuf2.0-0
            - libsqlite0
            - libsqlite3-0
            - libgl1-mesa-dev
            - libmagic1
            - libfuse2
            - libacl1
            - libattr1
            - libstdc++6
            - libgcc1
            - lvm2
            - libblkid1
            - libncurses5

service can not be started

sudo systemctl status snap.veeam.veeamservice.service 
● snap.veeam.veeamservice.service - Service for snap application veeam.veeamservice
   Loaded: loaded (/etc/systemd/system/snap.veeam.veeamservice.service; enabled; vendor preset: enabled)
   Active: failed (Result: core-dump) since Sat 2018-09-01 13:32:56 CEST; 5min ago
  Process: 11833 ExecStart=/usr/bin/snap run veeam.veeamservice (code=dumped, signal=SEGV)
 Main PID: 11833 (code=dumped, signal=SEGV)

сен 01 13:32:56 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
сен 01 13:32:56 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Scheduled restart job, restart counter is at 5.
сен 01 13:32:56 blin-System-Product-Name systemd[1]: Stopped Service for snap application veeam.veeamservice.
сен 01 13:32:56 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Start request repeated too quickly.
сен 01 13:32:56 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result 'core-dump'.
сен 01 13:32:56 blin-System-Product-Name systemd[1]: Failed to start Service for snap application veeam.veeamservice.

did you check what errors there are exactly when the serivice tries to start ?

do the following: open two terminals and put them next to each other, run journalctl -f in one of them … i tend to hit enter a few times in that termianl to make sure i can easily find where my logging started.

now run sudo snap restart veeam in the other terminal and look for errors from the veeamservice process but also “audit” and “DENIED” messages.

I did as you wrote.
journalctl -f
сен 01 14:00:24 blin-System-Product-Name sudo[12405]: blin : TTY=pts/1 ; PWD=/home/blin ; USER=root ; COMMAND=/usr/bin/snap restart veeam
сен 01 14:00:24 blin-System-Product-Name sudo[12405]: pam_unix(sudo:session): session opened for user root by (uid=0)
сен 01 14:00:24 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 01 14:00:24 blin-System-Product-Name audit[12420]: AVC apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12420 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name audit[12420]: AVC apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12420 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: kauditd_printk_skb: 5 callbacks suppressed
сен 01 14:00:24 blin-System-Product-Name kernel: audit: type=1400 audit(1535803224.136:380): apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12420 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: audit: type=1400 audit(1535803224.136:381): apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12420 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: veeamservice[12420]: segfault at 0 ip 0000000000000000 sp 00007fffacb51ab8 error 14 in veeamservice[400000+1288000]
сен 01 14:00:24 blin-System-Product-Name sudo[12405]: pam_unix(sudo:session): session closed for user root
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Main process exited, code=dumped, status=11/SEGV
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result ‘core-dump’.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Scheduled restart job, restart counter is at 1.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: Stopped Service for snap application veeam.veeamservice.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 01 14:00:24 blin-System-Product-Name audit[12437]: AVC apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12437 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name audit[12437]: AVC apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12437 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: audit: type=1400 audit(1535803224.608:382): apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12437 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: audit: type=1400 audit(1535803224.608:383): apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12437 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: veeamservice[12437]: segfault at 0 ip 0000000000000000 sp 00007ffed957c188 error 14 in veeamservice[400000+1288000]
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Main process exited, code=dumped, status=11/SEGV
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result ‘core-dump’.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Scheduled restart job, restart counter is at 2.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: Stopped Service for snap application veeam.veeamservice.
сен 01 14:00:24 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 01 14:00:24 blin-System-Product-Name audit[12453]: AVC apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12453 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name audit[12453]: AVC apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12453 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: audit: type=1400 audit(1535803224.856:384): apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12453 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: audit: type=1400 audit(1535803224.856:385): apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12453 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:24 blin-System-Product-Name kernel: veeamservice[12453]: segfault at 0 ip 0000000000000000 sp 00007ffd48e5c668 error 14 in veeamservice[400000+1288000]
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Main process exited, code=dumped, status=11/SEGV
сен 01 14:00:24 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result ‘core-dump’.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Scheduled restart job, restart counter is at 3.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: Stopped Service for snap application veeam.veeamservice.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 01 14:00:25 blin-System-Product-Name audit[12469]: AVC apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12469 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:25 blin-System-Product-Name audit[12469]: AVC apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12469 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:25 blin-System-Product-Name kernel: audit: type=1400 audit(1535803225.112:386): apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12469 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Main process exited, code=dumped, status=11/SEGV
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result ‘core-dump’.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Scheduled restart job, restart counter is at 4.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: Stopped Service for snap application veeam.veeamservice.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: Started Service for snap application veeam.veeamservice.
сен 01 14:00:25 blin-System-Product-Name audit[12486]: AVC apparmor=“ALLOWED” operation=“open” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12486 comm=“veeamservice” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=0
сен 01 14:00:25 blin-System-Product-Name audit[12486]: AVC apparmor=“ALLOWED” operation=“file_mmap” profile=“snap.veeam.veeamservice” name="/snap/core/5328/lib/x86_64-linux-gnu/libuuid.so.1.3.0" pid=12486 comm=“veeamservice” requested_mask=“rm” denied_mask=“rm” fsuid=0 ouid=0
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Main process exited, code=dumped, status=11/SEGV
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result ‘core-dump’.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Service hold-off time over, scheduling restart.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Scheduled restart job, restart counter is at 5.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: Stopped Service for snap application veeam.veeamservice.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Start request repeated too quickly.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: snap.veeam.veeamservice.service: Failed with result ‘core-dump’.
сен 01 14:00:25 blin-System-Product-Name systemd[1]: Failed to start Service for snap application veeam.veeamservice.

can you put triple backticks around such pastes please, else the output gets unreadable…