Accelerometer in Apple Watch, WatchOS

Hello 👋🏼 I would like to create my own Apple Watch app for workouts. I would like to count the number of repetitions of the exercise that I do for example (squat). But my watch is going to sleep. And when the device goes into sleep mode, the counter stops counting, and I wanted to ask. Does the accelerometer run in the background so that it counts the number of squats in the background? What can you recommend ?