Struct RunUser

Source
pub struct RunUser(/* private fields */);
Expand description

Information of a transient service for running on the per-user service manager.

Implementations§

Source§

impl RunUser

Source

pub fn new<T: AsRef<str>>(path: T) -> Self

Create a new RunUser from a path to executable.

Source

pub fn arg<T: AsRef<str>>(self, arg: T) -> Self

Append an argument to the command line.

Source

pub fn args<T: AsRef<str>, I: IntoIterator<Item = T>>(self, args: I) -> Self

Append multiple arguments to the command line.

Source

pub fn service_name<T: AsRef<str>>(self, name: T) -> Self

Set a custom name for the transient service.

If the name is not terminated with .service, it will be appended automatically.

Source

pub fn collect_on_fail(self) -> Self

Unload the transient service even if it fails.

This is not available if systemd_236 is disabled.

Read CollectMode= in systemd.unit(5) for details.

Source

pub fn runtime_max(self, d: Duration) -> Self

Configure a maximum time for the service to run. If this is used and the service has been active for longer than the specified time it is terminated and put into a failure state.

A Duration exceeding u64::MAX microseconds is trimmed to u64::MAX microseconds silently.

Read RuntimeMaxSec= in systemd.service(5) for details.

This setting will be unavailable with the feature systemd_229 disabled.

Source

pub fn memory_max(self, d: Byte) -> Self

Specify the absolute limit on memory usage of the executed processes in this unit. If memory usage cannot be contained under the limit, out-of-memory killer is invoked inside the unit.

A Byte exceeding u64::MAX bytes is trimmed to u64::MAX bytes silently.

Read MemoryMax= in systemd.resource-control(5) for details.

If the feature systemd_231 is disabled, MemoryLimit= will be used instead if MemoryMax= for compatibility.

Source

pub fn memory_swap_max(self, d: Byte) -> Self

Specify the absolute limit on swap usage of the executed processes in this unit.

This setting is supported only if the unified control group is used, so it’s not available if the feature unified_cgroup is disabled. And it will be unavailable with systemd_232 disabled.

A Byte exceeding u64::MAX bytes is trimmed to u64::MAX bytes silently.

Read MemorySwapMax= in systemd.resource-control(5) for details.

Source

pub fn limit_fsize_soft_hard(self, soft: Byte, hard: Byte) -> Self

Set soft and hard limits of the maximum size in bytes of files that the process may create.

Read LimitFSIZE= in systemd.exec(5) and RLIMIT_FSIZE in prlimit(2) for details.

Any setting exceeding u64::MAX bytes will be trimmed to u64::MAX bytes silently. And, if soft is greater than hard, it will be trimmed to hard silently.

Unlike RunSystem::limit_fsize_soft_hard, this can’t be used to increase the hard limit because of insufficient privileges.

Source

pub fn limit_fsize(self, lim: Byte) -> Self

Shorthand for self.limit_fsize_soft_hard(lim, lim).

Source

pub fn limit_core_soft_hard(self, soft: Byte, hard: Byte) -> Self

Set soft and hard limits of the maximum size in bytes of files that the process may create.

Any setting exceeding u64::MAX bytes will be trimmed to u64::MAX bytes silently. And, if soft is greater than hard, it will be trimmed to hard silently.

Read LimitCORE= in systemd.exec(5) and RLIMIT_CORE in prlimit(2) for details.

Unlike RunSystem::limit_core_soft_hard, this can’t be used to increase the hard limit because of insufficient privileges.

Source

pub fn limit_core(self, lim: Byte) -> Self

Shorthand for self.limit_fsize_soft_hard(lim, lim).

Source

pub fn limit_nproc_soft_hard(self, soft: NonZeroU64, hard: NonZeroU64) -> Self

Set soft and hard limits of the number of threads for the real user ID of the process.

If soft is greater than hard, it will be trimmed to hard silently.

Read LimitNPROC= in systemd.exec(5) and RLIMIT_NPROC in prlimit(2) for details.

Unlike RunSystem::limit_nproc_soft_hard, this can’t be used to increase the hard limit because of insufficient privileges.

Source

pub fn limit_nproc(self, lim: NonZeroU64) -> Self

Shorthand for self.limit_nproc_soft_hard(lim, lim).

Source

pub fn limit_nofile_soft_hard(self, soft: NonZeroU64, hard: NonZeroU64) -> Self

Set soft and hard limits of the number of threads for the real user ID of the process.

If soft is greater than hard, it will be trimmed to hard silently.

Read LimitNOFILE= in systemd.exec(5) and RLIMIT_NOFILE in prlimit(2) for details.

Unlike RunSystem::limit_nofile_soft_hard, this can’t be used to increase the hard limit because of insufficient privileges.

Source

pub fn limit_nofile(self, lim: NonZeroU64) -> Self

Shorthand for self.limit_nofile_soft_hard(lim, lim).

Source

pub fn limit_stack_soft_hard(self, soft: Byte, hard: Byte) -> Self

Set the soft and hard limit on the size of the process stack.

If soft is greater than hard, it will be trimmed to hard silently.

Read LimitSTACK= in systemd.exec(5) and RLIMIT_STACK in prlimit(2) for details.

Unlike RunSystem::limit_stack_soft_hard, this can’t be used to increase the hard limit because of insufficient privileges.

Source

pub fn limit_stack(self, lim: Byte) -> Self

Shorthand for self.limit_stack_soft_hard(lim, lim).

Source

pub fn stdin(self, spec: InputSpec) -> Self

Controls where file descriptor 0 (STDIN) of the executed processes is connected to.

Read InputSpec and StandardInput= in systemd.exec(5) for details.

The default is InputSpec::null().

Source

pub fn stdout(self, spec: OutputSpec) -> Self

Controls where file descriptor 1 (STDOUT) of the executed processes is connected to.

Read OutputSpec and StandardOutput= in systemd.exec(5) for details.

The default depends on system configuration.

Source

pub fn stderr(self, spec: OutputSpec) -> Self

Controls where file descriptor 2 (STDERR) of the executed processes is connected to.

Read OutputSpec and StandardError= in systemd.exec(5) for details.

The default depends on system configuration.

Source

pub fn current_dir<P: AsRef<str>>(self, path: P) -> Self

Sets the working directory for executed processes.

Read WorkingDirectory= in systemd.exec(5) for details.

This setting is unavailable with the feature systemd_227 disabled.

Source

pub fn slice<S: AsRef<str>>(self, slice: S) -> Self

Put the transient service into a slice.

Read Slice= in systemd.resource-control(5) for details.

Source

pub fn private_users(self) -> Self

Sets up a new user namespace for the executed processes and configures a minimal user and group mapping.

Read PrivateUsers= in systemd.exec(5) for details.

This setting is unavailable with the feature systemd_251 disabled.

Source

pub fn timeout_stop(self, d: Duration) -> Self

Configure the time to wait for the service itself to stop. If the service doesn’t terminate in the specified time, it will be forcibly terminated by SIGKILL.

A Duration exceeding u64::MAX microseconds is trimmed to u64::MAX microseconds silently.

Read TimeoutStopSec= in systemd.service(5) for details.

This setting will be unavailable with the feature systemd_188 disabled.

Source

pub async fn start<'a>(self) -> Result<StartedRun<'a>>

Start the transient service.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more