Skip to content

feat(systemd): add WantedBy option with default multi-user.target#415

Open
kongfei605 wants to merge 1 commit intokardianos:masterfrom
kongfei605:systemd_up
Open

feat(systemd): add WantedBy option with default multi-user.target#415
kongfei605 wants to merge 1 commit intokardianos:masterfrom
kongfei605:systemd_up

Conversation

@kongfei605
Copy link
Copy Markdown

@kongfei605 kongfei605 commented Dec 10, 2025

Background
When installing a service as a systemd user service (with UserService option set to true), the generated unit file uses WantedBy=multi-user.target by default. However, multi-user.target does not exist in the user systemd instance, which causes the service to fail to start on user login.

Problem
For user services, the correct target should be default.target instead of multi-user.target. Currently, there is no way to customize the WantedBy directive without providing a complete custom systemd script template via the SystemdScript option.

Solution
This PR adds a new WantedBy option that allows users to specify the systemd target:

Default value: multi-user.target (backward compatible)
For user services: users can set it to default.target

svcConfig := &service.Config{
    Name:        "myservice",
    DisplayName: "My Service",
    Description: "My service description",
    Option: service.KeyValue{
        "UserService": true,
        "WantedBy":    "default.target",
    },
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant