LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-12-2019, 08:47 AM   #1
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Rep: Reputation: Disabled
need help with creating a systemd unit file.


I am trying to start some rails workers on startup, the command to do this is :

RAILS_ENV=development bundle exec rails resque:start_workers[2]


I put in a unitfile with the following:
Code:
[Unit]
Description=background workers
After=httpd.service solr.service

[Service]
Environment=RAILS_ENV=development
ExecStart=/usr/local/bin/bundle exec rails resque:restart_workers[2]
User=deploy
WorkingDirectory=/opt/wonda/current
Environment=rvm_bin_path=/usr/local/rvm/bin
Environment=GEM_HOME=/usr/local/rvm/gems/ruby-2.5.1
Environment=SHELL=/bin/bash
Environment=IRBRC=/usr/local/rvm/rubies/ruby-2.5.1/.irbrc
Environment=MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.5.1
Environment=LD_LIBRARY_PATH=/opt/rh/rh-php71/root/usr/lib64
Environment=PATH=/usr/local/rvm/gems/ruby-2.5.1/bin:/usr/local/rvm/gems/ruby-2.5.1@global/bin:/usr/local/rvm/rubies/ruby-2.5.1/bin:/usr/local/rvm/bin:/opt/rh/rh-php71/root/usr/bin:/opt/rh/rh-php71/root/usr/sbin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/sbin:/usr/local/sbin:/opt/puppetlabs/bin
Environment=GEM_PATH=/usr/local/rvm/gems/ruby-2.5.1:/usr/local/rvm/gems/ruby-2.5.1@global
Environment=DBUSER=wonda
Environment=DBPASS=***************

[Install]
WantedBy=multi-user.target
It appears to start the workers, but they never actually start, I assume thier processes are dieing immediately.

Can anyone help or spot what I am doing wrong? Note that all the Environment was me trying to replicate the users environment.

Last edited by thaylin; 07-12-2019 at 12:19 PM.
 
Old 07-12-2019, 09:12 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,125

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260
What do you get from:
Code:
systemctl status <your service name>
and do the workers log any messages?
 
Old 07-12-2019, 12:19 PM   #3
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
What do you get from:
Code:
systemctl status <your service name>
and do the workers log any messages?
No messages, though I do see

Code:
Jul 12 09:29:37 wonda bundle[16935]: Starting 2 worker(s) with QUEUE: ingest,mailers,checksum
Jul 12 09:29:37 wonda bundle[16935]: Started worker with PID 16945
Jul 12 09:29:37 wonda bundle[16935]: Started worker with PID 16947
But those PIDs are dead by the time I check.
 
Old 07-12-2019, 12:42 PM   #4
thaylin
LQ Newbie
 
Registered: Oct 2015
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
What do you get from:
Code:
systemctl status <your service name>
and do the workers log any messages?
we added some deug logging but all it outputs is

Code:
D, [2019-07-12T13:39:54.937421 #29170] DEBUG -- : Checking ingest
D, [2019-07-12T13:39:54.938149 #29170] DEBUG -- : Checking mailers
D, [2019-07-12T13:39:54.938574 #29170] DEBUG -- : Checking checksum
D, [2019-07-12T13:39:54.938896 #29170] DEBUG -- : Sleeping for 5.0 seconds
D, [2019-07-12T13:39:54.939002 #29170] DEBUG -- : resque-2.0.0: Waiting for ingest,mailers,checksum
 
Old 07-13-2019, 12:17 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,795

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by thaylin View Post
I am trying to start some rails workers on startup, the command to do this is :

RAILS_ENV=development bundle exec rails resque:start_workers[2]


I put in a unitfile with the following:
Code:
<snip>

[Service]
Environment=RAILS_ENV=development
ExecStart=/usr/local/bin/bundle exec rails resque:restart_workers[2]
User=deploy
WorkingDirectory=/opt/wonda/current
Environment=rvm_bin_path=/usr/local/rvm/bin
Environment=GEM_HOME=/usr/local/rvm/gems/ruby-2.5.1
Environment=SHELL=/bin/bash
Environment=IRBRC=/usr/local/rvm/rubies/ruby-2.5.1/.irbrc
Environment=MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.5.1

<snip>
It appears to start the workers, but they never actually start, I assume thier processes are dieing immediately.

Can anyone help or spot what I am doing wrong? Note that all the Environment was me trying to replicate the users environment.
Not sure how much I can help---I've not tackled a unit file quite like this.

While the documentation says that multiple instances of "Environment=" should work but it wouldn't be the first time the "fine manual" was in error.

Would something like this work?
Code:
Environment=RAILS_ENV=development \
  rvm_bin_path=/usr/local/rvm/bin \
  GEM_HOME=/usr/local/rvm/gems/ruby-2.5.1 \
  SHELL=/bin/bash \
  (etc.)
Worth a try.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do we get my UNIT(service) name in unit.sevice Boobalan M Linux - Software 6 01-23-2018 05:03 AM
Creating a systemd unit for performing a particular action when the network goes down emacsomancer Linux - Software 0 11-06-2015 09:46 PM
Creating a systemd unit for gcr raisdead Linux - Newbie 1 11-12-2014 05:32 PM
LXer: Hybrid RAID 1 (Mirror) of RAM drive & SATA HDD Using LVM with LUKS [and systemd unit file] on LXer Syndicated Linux News 0 07-29-2014 10:40 AM
Storage unit and IO unit salmanucit Linux - General 2 06-17-2008 11:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration