Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
Start systemd user service from Rails

I need to start a systemd service from Ruby on Rails. My ruby code is using backticks to call systemctl:

`systemctl --user start myservice`

It's not working and I think it's to do with the user that command is executed by. Rails is running on Passenger and the user for that should be the same as my service.

I've also tried alternative ways to launch a subprocess

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

(This should be a comment rather than an answer, but I'm still building 'reputation' points, so...)

If Passenger has the same UID that myservice needs to run, then that's not where the problem lies. Nor are the other ways of launching a child likely to change the outcome.

I suggest capturing the output of the subprocess as follows: systemctl --user start myservice > /tmp/systemctl.output 2>&1 and then inspecting the output file after the subprocess fails.

over 4 years ago · Santiago Trujillo Report

0

I was able to solve the issue by telling the shell where to find the correct DBUS for the user. I set the environment variable XDG_RUNTIME_DIR to the location of DBUS for the user, 1001 in my case. Check echo $UID to find user id, I couldn't use this inline.

`export XDG_RUNTIME_DIR="/run/user/1001" && systemctl --user start myservice`

Thanks to D.j. Molny for the initial sign post and NeilCasey for the remainder

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!