Monit and /etc/environment

4

我在/etc/environment设置了RAILS_ENV='production'变量,并编写了一个简单的bash脚本。

#!/bin/bash
printenv

在monit配置文件中,我检查是否正在运行此脚本(仅用于测试目的,因为没有这样的进程,monit应该尝试使用以下命令启动它:start program = "/home/deploy/www/laptophits/current/bin/importer")。
在monit日志中,我收到错误信息:
[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

看起来这个bash脚本只是使用了一些简单的monit变量。我该如何使它运行时能够使用/etc/variables和/或用户变量?

2个回答

1
要在monit中加载/etc/environment变量,您需要使用
例如;
  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

这将加载用户环境和 /etc/environment 文件。

0

你可以这样运行你的命令:

start program = "/bin/bash -c '/home/deploy/www/laptophits/current/bin/importer'" as uid **username** and gid **group**

Shell会加载用户的环境。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接