code: func (w *worker) Init(ctx context.Context) error {
  	w.mu.Lock()
  	defer w.mu.Unlock()
  
  	ctx = log.WithModule(ctx, "worker")
  
  	// TODO(stevvooe): Start task cleanup process.
  
  	// read the tasks from the database and start any task managers that may be needed.
  	return w.db.Update(func(tx *bolt.Tx) error {
  		return WalkTasks(tx, func(task *api.Task) error {
  			if !TaskAssigned(tx, task.ID) {
  				// NOTE(stevvooe): If tasks can survive worker restart, we need
  				// to startup the controller and ensure they are removed. For
  				// now, we can simply remove them from the database.
  				if err := DeleteTask(tx, task.ID); err != nil {
  					log.G(ctx).WithError(err).Errorf("error removing task %v", task.ID)
  				}
  				return nil
  			}
  
  			status, err := GetTaskStatus(tx, task.ID)
  			if err != nil {
  				log.G(ctx).WithError(err).Error("unable to read tasks status")
  				return nil
  			}
  
  			task.Status = *status // merges the status into the task, ensuring we start at the right point.
  			return w.startTask(ctx, tx, task)
  		})
  	})
  }
docs: // Init prepares the worker for assignments.