Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Problema con servizio

  1. #1

    Problema con servizio

    Ciao,
    ho un problema nella creazione di un servizio, va in errore e non riesco a capire il motivo.
    Ho anche provato a creare un servizio "stupido" di esempio:

    codice:
    $ uname -a
    Linux test02 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    $ mkdir server
    $ cd server
    $ touch test.daemon
    $ chmod +rx test.daemon
    $ nano test.daemon
    questo è il contenuto di test.daemon:

    codice:
    ### BEGIN INIT INFO
    # Provides:          test
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start test at boot time
    # Description:       Just a test
    ### END INIT INFO
    
    
    #!/bin/bash
    # chkconfig: 2345 20 80
    # description: test
    
    # Source function library.
    #. /etc/init.d/functions
    
    start() {
        # code to start app comes here
        # example: daemon program_name &
            echo "test start"
    }
    
    
    stop() {
        # code to stop app comes here
        # example: killproc program_name
            echo "test stop"
    }
    
    
    case "$1" in
        start)
           start
           ;;
        stop)
           stop
           ;;
        restart)
           stop
           start
           ;;
        *)
           echo "Usage: $0 {start|stop|restart}"
    esac
    
    
    exit 0
    dopodiche..

    codice:
    $ cd /etc/init.d/
    $ sudo -s
    # ln -s /home/utente/server/test.daemon test
    # ls -la
    lrwxrwxrwx  1 root root   35 Jan 21 13:56 discosrv.daemon -> /home/utente/server/discosrv.daemon
    # update-rc.d test defaults
    # service test start
    Job for test.service failed because the control process exited with error code. See "systemctl status test.service" and "journalctl -xe" for details.
    codice:
    # systemctl status test.service
    â— test.service - LSB: Start test at boot time
       Loaded: loaded (/etc/init.d/test; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sat 2017-01-21 14:05:13 UTC; 31s ago
         Docs: man:systemd-sysv-generator(8)
      Process: 1957 ExecStart=/etc/init.d/test start (code=exited, status=203/EXEC)
    
    
    Jan 21 14:05:13 test02 systemd[1]: Starting LSB: Start test at boot time...
    Jan 21 14:05:13 test02 systemd[1]: test.service: Control process exited, code=exited status=203
    Jan 21 14:05:13 test02 systemd[1]: Failed to start LSB: Start test at boot time.
    Jan 21 14:05:13 test02 systemd[1]: test.service: Unit entered failed state.
    Jan 21 14:05:13 test02 systemd[1]: test.service: Failed with result 'exit-code'.
    codice:
    # journalctl -xe
    --
    -- The start-up result is done.
    Jan 21 14:03:43 test02 python3[1216]: 2017/01/21 14:03:43.609062 INFO Agent WALinuxAgent-2.1.5 launched with command 'python3 -u /usr/sbin/waagent -run-exthandlers' is
    Jan 21 14:03:43 test02 python3[1216]: 2017/01/21 14:03:43.649888 INFO Event: name=WALinuxAgent, op=Enable, message=Agent WALinuxAgent-2.1.5 launched with command 'pytho
    Jan 21 14:05:03 test02 systemd[1]: Reloading.
    Jan 21 14:05:03 test02 systemd-sysv-generator[1912]: stat() failed on /etc/init.d/discosrv.daemon, ignoring: No such file or directory
    Jan 21 14:05:03 test02 systemd[1]: apt-daily.timer: Adding 4h 56min 31.370059s random time.
    Jan 21 14:05:03 test02 systemd[1]: snapd.refresh.timer: Adding 4h 21min 39.795374s random time.
    Jan 21 14:05:03 test02 systemd[1]: Started ACPI event daemon.
    -- Subject: Unit acpid.service has finished start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    --
    -- Unit acpid.service has finished starting up.
    --
    -- The start-up result is done.
    Jan 21 14:05:13 test02 systemd[1]: Starting LSB: Start test at boot time...
    -- Subject: Unit test.service has begun start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    --
    -- Unit test.service has begun starting up.
    Jan 21 14:05:13 test02 systemd[1957]: test.service: Failed at step EXEC spawning /etc/init.d/test: Exec format error
    -- Subject: Process /etc/init.d/test could not be executed
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    --
    -- The process /etc/init.d/test could not be executed and failed.
    --
    -- The error number returned by this process is 8.
    Jan 21 14:05:13 test02 systemd[1]: test.service: Control process exited, code=exited status=203
    Jan 21 14:05:13 test02 systemd[1]: Failed to start LSB: Start test at boot time.
    -- Subject: Unit test.service has failed
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    --
    -- Unit test.service has failed.
    --
    -- The result is failed.
    Jan 21 14:05:13 test02 systemd[1]: test.service: Unit entered failed state.
    Jan 21 14:05:13 test02 systemd[1]: test.service: Failed with result 'exit-code'.
    Jan 21 14:06:16 test02 sudo[1967]:   utente : TTY=pts/0 ; PWD=/home/utente/server ; USER=root ; COMMAND=/bin/bash
    Jan 21 14:06:16 test02 sudo[1967]: pam_unix(sudo:session): session opened for user root by utente(uid=0)
    cosa c'è di sbagliato?

  2. #2
    l'errore non e' questo? Failed to start LSB: Start test at boot time. provato a riavviare?

  3. #3
    ho modificato le 2 funzioni in questo modo per avere un feedback alla partenza:
    codice:
    start() {
        # code to start app comes here
        # example: daemon program_name &
            echo "test start $(date)" >> /home/utente/tmp/start.txt
    }
    
    
    stop() {
        # code to stop app comes here
        # example: killproc program_name
            echo "test stop $(date)" >> /home/utente/tmp/stop.txt
    }
    poi ho anche eseguito update-rc.d e riavviato, ma non ha generato niente

  4. #4
    adesso che vedi con:

    systemctl status test.service

    systemctl show test.service


    p.s.
    che distro?

  5. #5
    la distro è ubuntu server
    codice:
    Linux test02 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    questo è quello che viene mostrato dai 2 comandi:
    codice:
    systemctl status test.service
    ● test.service - LSB: Start test at boot time
       Loaded: loaded (/etc/init.d/test; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Mon 2017-01-23 09:06:10 UTC; 4h 54min ago
         Docs: man:systemd-sysv-generator(8)
      Process: 1337 ExecStart=/etc/init.d/test start (code=exited, status=203/EXEC)
    
    Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
    codice:
    Type=forking
    Restart=no
    NotifyAccess=none
    RestartUSec=100ms
    TimeoutStartUSec=5min
    TimeoutStopUSec=5min
    RuntimeMaxUSec=infinity
    WatchdogUSec=0
    WatchdogTimestampMonotonic=0
    FailureAction=none
    PermissionsStartOnly=no
    RootDirectoryStartOnly=no
    RemainAfterExit=yes
    GuessMainPID=no
    MainPID=0
    ControlPID=0
    FileDescriptorStoreMax=0
    NFileDescriptorStore=0
    StatusErrno=0
    Result=exit-code
    ExecMainStartTimestampMonotonic=0
    ExecMainExitTimestampMonotonic=0
    ExecMainPID=0
    ExecMainCode=0
    ExecMainStatus=0
    ExecStart={ path=/etc/init.d/test ; argv[]=/etc/init.d/test start ; ignore_errors=no ; start_time=[Mon 2017-01-23 09:06:09 UTC] ; stop_time=[Mon 2017-01-23 09:06:10 UTC] ; pid=1337 ; code=exited ; status=203 }
    ExecStop={ path=/etc/init.d/test ; argv[]=/etc/init.d/test stop ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
    Slice=system.slice
    MemoryCurrent=18446744073709551615
    CPUUsageNSec=18446744073709551615
    TasksCurrent=18446744073709551615
    Delegate=no
    CPUAccounting=no
    CPUShares=18446744073709551615
    StartupCPUShares=18446744073709551615
    CPUQuotaPerSecUSec=infinity
    BlockIOAccounting=no
    BlockIOWeight=18446744073709551615
    StartupBlockIOWeight=18446744073709551615
    MemoryAccounting=no
    MemoryLimit=18446744073709551615
    DevicePolicy=auto
    TasksAccounting=no
    TasksMax=18446744073709551615
    UMask=0022
    LimitCPU=18446744073709551615
    LimitCPUSoft=18446744073709551615
    LimitFSIZE=18446744073709551615
    LimitFSIZESoft=18446744073709551615
    LimitDATA=18446744073709551615
    LimitDATASoft=18446744073709551615
    LimitSTACK=18446744073709551615
    LimitSTACKSoft=8388608
    LimitCORE=18446744073709551615
    LimitCORESoft=0
    LimitRSS=18446744073709551615
    LimitRSSSoft=18446744073709551615
    LimitNOFILE=4096
    LimitNOFILESoft=1024
    LimitAS=18446744073709551615
    LimitASSoft=18446744073709551615
    LimitNPROC=2513
    LimitNPROCSoft=2513
    LimitMEMLOCK=65536
    LimitMEMLOCKSoft=65536
    LimitLOCKS=18446744073709551615
    LimitLOCKSSoft=18446744073709551615
    LimitSIGPENDING=2513
    LimitSIGPENDINGSoft=2513
    LimitMSGQUEUE=819200
    LimitMSGQUEUESoft=819200
    LimitNICE=0
    LimitNICESoft=0
    LimitRTPRIO=0
    LimitRTPRIOSoft=0
    LimitRTTIME=18446744073709551615
    LimitRTTIMESoft=18446744073709551615
    OOMScoreAdjust=0
    Nice=0
    IOScheduling=0
    CPUSchedulingPolicy=0
    CPUSchedulingPriority=0
    TimerSlackNSec=50000
    CPUSchedulingResetOnFork=no
    NonBlocking=no
    StandardInput=null
    StandardOutput=journal
    StandardError=inherit
    TTYReset=no
    TTYVHangup=no
    TTYVTDisallocate=no
    SyslogPriority=30
    SyslogLevelPrefix=yes
    SyslogLevel=6
    SyslogFacility=3
    SecureBits=0
    CapabilityBoundingSet=18446744073709551615
    AmbientCapabilities=0
    MountFlags=0
    PrivateTmp=no
    PrivateNetwork=no
    PrivateDevices=no
    ProtectHome=no
    ProtectSystem=no
    SameProcessGroup=no
    UtmpMode=init
    IgnoreSIGPIPE=no
    NoNewPrivileges=no
    SystemCallErrorNumber=0
    RuntimeDirectoryMode=0755
    KillMode=process
    KillSignal=15
    SendSIGKILL=yes
    SendSIGHUP=no
    Id=test.service
    Names=test.service
    Requires=system.slice sysinit.target
    WantedBy=graphical.target multi-user.target
    Conflicts=shutdown.target
    Before=multi-user.target graphical.target shutdown.target
    After=system.slice systemd-journald-dev-log.socket remote-fs.target basic.target sysinit.target systemd-journald.socket
    Documentation=man:systemd-sysv-generator(8)
    Description=LSB: Start test at boot time
    LoadState=loaded
    ActiveState=failed
    SubState=failed
    FragmentPath=/run/systemd/generator.late/test.service
    SourcePath=/etc/init.d/test
    UnitFileState=bad
    UnitFilePreset=enabled
    StateChangeTimestamp=Mon 2017-01-23 09:06:10 UTC
    StateChangeTimestampMonotonic=39495648
    InactiveExitTimestamp=Mon 2017-01-23 09:06:09 UTC
    InactiveExitTimestampMonotonic=39216739
    ActiveEnterTimestampMonotonic=0
    ActiveExitTimestampMonotonic=0
    InactiveEnterTimestamp=Mon 2017-01-23 09:06:10 UTC
    InactiveEnterTimestampMonotonic=39495648
    CanStart=yes
    CanStop=yes
    CanReload=no
    CanIsolate=no
    StopWhenUnneeded=no
    RefuseManualStart=no
    RefuseManualStop=no
    AllowIsolate=no
    DefaultDependencies=yes
    OnFailureJobMode=replace
    IgnoreOnIsolate=no
    NeedDaemonReload=no
    JobTimeoutUSec=infinity
    JobTimeoutAction=none
    ConditionResult=yes
    AssertResult=yes
    ConditionTimestamp=Mon 2017-01-23 09:06:09 UTC
    ConditionTimestampMonotonic=39215980
    AssertTimestamp=Mon 2017-01-23 09:06:09 UTC
    AssertTimestampMonotonic=39215980
    Transient=no
    StartLimitInterval=10000000
    StartLimitBurst=5
    StartLimitAction=none

  6. #6
    ho fatto una prova anche io

    e soltanto aggiungendo:
    codice:
    #!/bin/bash
    in testa non ho avuto errori

    ho seguito:
    http://guide.debianizzati.org/index....vizi_in_Debian

  7. #7
    wow ora funziona! l'errore era proprio quello, accidentalmente non l'avevo messo come prima riga
    grazie per l'aiuto!

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.