Linux - Server This forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
07-12-2019, 08:47 AM
#1
LQ Newbie
Registered: Oct 2015
Posts: 22
Rep:
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 .
07-12-2019, 09:12 AM
#2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,125
What do you get from:
Code:
systemctl status <your service name>
and do the workers log any messages?
07-12-2019, 12:19 PM
#3
LQ Newbie
Registered: Oct 2015
Posts: 22
Original Poster
Rep:
Quote:
Originally Posted by
smallpond
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.
07-12-2019, 12:42 PM
#4
LQ Newbie
Registered: Oct 2015
Posts: 22
Original Poster
Rep:
Quote:
Originally Posted by
smallpond
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
07-13-2019, 12:17 PM
#5
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
Quote:
Originally Posted by
thaylin
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.
All times are GMT -5. The time now is 04:22 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News