Reputation: 3659
I have RAILS_ENV='production'
variable set in /etc/environment
, and simple bash script
#!/bin/bash
printenv
In monit config I check if this script is running.(it's for testing purposes only, as there is no process like this, monit should try to start it with:
start program = "/home/deploy/www/laptophits/current/bin/importer"
)
I get error in monit logs:
[UTC Sep 3 09:31:50] error : 'importer' failed to start (exit status 0) -- /home/deploy/www/laptophits/current/bin/importer: MONIT_DATE=Sun, 03 Sep 2017 09:31:20
MONIT_HOST=localhost
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
MONIT_PROCESS_PID=-1
MONIT_EVENT=Started
MONIT_PROCESS_MEM
So it looks like this bash script runs with just some simple monit variables. How can I make it to run with /etc/variables
and/or user variables?
Upvotes: 4
Views: 1885
Reputation: 5126
To load the /etc/environment variable within monit you have to use source /etc/environment
eg;
start program = "/bin/bash -c 'source /etc/environment && cd /srv/<project>/current && /usr/local/rbenv/shims/bundle exec sidekiq -d -L log/sidekiq.log -C config/sidekiq.yml -e production'" as uid 1000 and gid 1000
This will load both the users environment and the /etc/environment file.
Upvotes: 1
Reputation: 1223
You can run your command as:
start program = "/bin/bash -c '/home/deploy/www/laptophits/current/bin/importer'" as uid **username** and gid **group**
the shell will load the user's environment.
Upvotes: 0