# How to perform "safe" stop of mender-client

**URL:** <https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487>\
**Category:** General Discussions\
**Created:** [September 24, 2020, 12:04pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487 "2020-09-24T12:04:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeli](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joeli](https://hub.mender.io/u/joeli)\
**Post date:** [September 24, 2020, 12:04pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/1 "2020-09-24T12:04:03Z")

</div>

Hi,

I am trying to stop the mender-client after a software update. At first I was doing this with a state-script ArtifactCommit\_Leave\_…, but doing so made the status of the mender-server stuck at “rebooting”.

My second try was to create a flag when running ArtifactCommit\_Leave… and then stop mender-client with a script Idle\_Enter…, that seems to work, now the mender-server reports “success”, but …  
When starting the client again the system always reboots and looking into the logfiles I found:

{“level”:“info”,“message”:“State transition: cleanup [none] -\u003e update-status-report [none]”,“timestamp”:“2020-09-23T09:13:23Z”} N.B. Last message before stopping client.  
{“level”:“info”,“message”:“Running Mender client version: 2.3.0-dirty”,“timestamp”:“2020-09-24T09:18:05Z”}  
{“level”:“error”,“message”:“Mender shut down in state: update-status-report”,“timestamp”:“2020-09-24T09:18:05Z”}  
{“level”:“info”,“message”:“State transition: init [none] -\u003e rollback [ArtifactRollback]”,“timestamp”:“2020-09-24T09:18:05Z”}  
{“level”:“info”,“message”:“Performing rollback”,“timestamp”:“2020-09-24T09:18:05Z”}

So even though I stopped the client with the state script name Idle\_Enter…, there seems to be a “sub-state” or something “update-status-report” that has not finished.

How can I perform a stable stop of the mender-client. Is it better to do it in Idle\_Leave…

Best regards,  
Jonny

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 24, 2020, 12:40pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/2 "2020-09-24T12:40:47Z")

</div>

Just a question first:

- If you are going to kill the daemon anyhow, why are you not using standalone mode?

---

<div class="post-metadata">

**Author:** ![joeli](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joeli](https://hub.mender.io/u/joeli)\
**Post date:** [September 24, 2020, 12:46pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/3 "2020-09-24T12:46:20Z")

</div>

Hi,  
my picture is that when you use standalone mode you point out an URI to something to install, but we would like to use the mender-server as well.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [September 24, 2020, 5:04pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/4 "2020-09-24T17:04:41Z")

</div>

> sudo systemctl stop mender-client

should do it.

---

<div class="post-metadata">

**Author:** ![joeli](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joeli](https://hub.mender.io/u/joeli)\
**Post date:** [September 24, 2020, 5:27pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/5 "2020-09-24T17:27:58Z")

</div>

@drewmoseley That is what I do in a state-script Idle\_Enter… but somehow when restarting mender-client it writes “Mender shut down in state: update-status-report” in the log-file ???

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 25, 2020, 8:37am UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/6 "2020-09-25T08:37:53Z")

</div>

What exactly is the use-case here, I’m curious? Does the Mender daemon consume too many resources? Do you need it to check for updates at specific times? Or what is going on here?

---

<div class="post-metadata">

**Author:** ![joeli](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joeli](https://hub.mender.io/u/joeli)\
**Post date:** [September 25, 2020, 9:13am UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/7 "2020-09-25T09:13:18Z")

</div>

It is a measurement system. We do not want to be interrupted by the client asking for new software. One customer can have 40 units and choosing to run the free Mender-Server version another 5 or 100 units and want to have the hosted version of the server. The system collects data, so there is already an existing data server platform. And via this interface we could decide when and which units that should perform the software upgrade. When new software arrives the customer will probably first test this on a couple of units, when satisfied, upgrade the units that is not currently on an assignment and then upgrade these when their assignments are finished.

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 25, 2020, 11:00am UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/8 "2020-09-25T11:00:36Z")

</div>

I know it doesn’t solve the “Mender client interrupts” problem, but we do have phased rollouts implemented in Enterprise. Which means that updates can by dynamically assigned to a group of devices based on your chosen device metric, and then even roll it out to a small group of devices in a first stage, and only proceed if this update is succesful. Would this fit you use-case?

For the running and stopping of the client, Maybe this can be done in the `Sync` state? based on some condition instead? This should keep you out of trouble with the spontanaeous reboot self-checks I think.

---

<div class="post-metadata">

**Author:** ![joeli](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joeli](https://hub.mender.io/u/joeli)\
**Post date:** [September 25, 2020, 12:08pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/9 "2020-09-25T12:08:28Z")

</div>

Thank you for the information. Moving the stop command to Sync\_Enter… solved the problem. Now I do not get any errors in the deployment logs.

For many customers your suggestion would probably work, but not for all, some companies do not want to have their data stored on hosted servers.

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 25, 2020, 12:36pm UTC](https://hub.mender.io/t/how-to-perform-safe-stop-of-mender-client/2487/10 "2020-09-25T12:36:27Z")

</div>

Great 🙂 Glad to hear it!

> For many customers your suggestion would probably work, but not for all, some companies do not want to have their data stored on hosted servers.

Yes, we are aware, and I totally understand. That’s why we also support a self-hosted version 😉

Best of luck!
