Skip to content

Service on Alpine can't properly shutdown (with solutions) #1326

Description

@lawipac

Netclient Version 1.6.0 ( also happens to 1.5.1 )
Alpine : 3.23

drive:~# rc-service netclient status
 * status: started
drive:~# rc-service netclient stop
 * Stopping netclient ...                                                                                                                                          [ ok ]
drive:~# rc-service netclient start
 * Starting netclient ...
 * supervise-daemon: /sbin/netclient is already running
 * failed to start netclient                                                                                                                                       [ !! ]
 * ERROR: netclient failed to start
drive:~# ps w | grep netclient
 2083 root      0:00 supervise-daemon netclient --start --stdout /var/log/netclient.log --stderr /var/log/netclient.log --pidfile /var/run/netclient.pid --respawn-delay 2 --respawn-max 3 --respawn-period 10 --user root /sbin/netclient -- daemon
 2617 root      0:00 /sbin/netclient daemon
 2852 root      0:00 grep netclient
drive:~#

The reason is the usage of supervisor="supervise-daemon"

drive:~# sed -n '1,200p' /etc/init.d/netclient
#!/sbin/openrc-run

description="netclient daemon"
pidfile="/var/run/netclient.pid"
RC_SVCNAME="netclient"
command="/sbin/netclient"
command_args="daemon"
command_user="root"
supervisor="supervise-daemon"
respawn_max=3
respawn_period=10
output_log="/var/log/netclient.log"
error_log="/var/log/netclient.log"
depend() {
        after firewall
}

drive:~#

By modifying default service settings from

command_args="daemon"
supervisor="supervise-daemon"

to

command_args="daemon"
command_background="yes"
# supervisor="supervise-daemon"

It can stop and restart the service properly and can support autorestart during accidents by

respawn_max=3
respawn_period=10

the complete final service /etc/init.d/netclient read as;

#!/sbin/openrc-run

description="netclient daemon"
pidfile="/var/run/netclient.pid"
RC_SVCNAME="netclient"
command="/sbin/netclient"
command_args="daemon"
command_user="root"
command_background="yes"
# supervisor="supervise-daemon"
respawn_max=3
respawn_period=10
output_log="/var/log/netclient.log"
error_log="/var/log/netclient.log"

depend() {
        after firewall
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions