Skip to content

Commit

Permalink
Updated anything writing to the top level logs directory. Now writes …
Browse files Browse the repository at this point in the history
…to a logs directory that is under the application directory. This is mainly pid files and build pack logs, but there are a few components which cannot write to stdout like php-fpm.
  • Loading branch information
Daniel Mikusa committed Sep 2, 2014
1 parent 63895ce commit e94d88b
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bin/rewrite
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ from build_pack_utils import utils
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s [%(levelname)s] %(name)s - %(message)s',
filename='../logs/rewrite.log')
filename='logs/rewrite.log')

if len(sys.argv) != 2:
print 'Argument required! Specify path to configuration directory.'
Expand Down
2 changes: 1 addition & 1 deletion bin/start
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if __name__ == '__main__':

logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s [%(levelname)s] %(name)s - %(message)s',
filename='../logs/proc-man.log')
filename='logs/proc-man.log')

home = os.environ['HOME']

Expand Down
2 changes: 1 addition & 1 deletion defaults/config/php/5.4.x/php-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pid = @{HOME}/php/var/run/php-fpm.pid
; in a local file.
; Note: the default prefix is /tmp/staged/app/php/var
; Default Value: log/php-fpm.log
error_log = @{HOME}/../logs/php-fpm.log
error_log = @{HOME}/logs/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
Expand Down
2 changes: 1 addition & 1 deletion defaults/config/php/5.5.x/php-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pid = @{HOME}/php/var/run/php-fpm.pid
; in a local file.
; Note: the default prefix is /tmp/staged/app/php/var
; Default Value: log/php-fpm.log
error_log = @{HOME}/../logs/php-fpm.log
error_log = @{HOME}/logs/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
Expand Down
2 changes: 1 addition & 1 deletion defaults/config/php/5.6.x/php-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pid = @{HOME}/php/var/run/php-fpm.pid
; in a local file.
; Note: the default prefix is /tmp/staged/app/php/var
; Default Value: log/php-fpm.log
error_log = @{HOME}/../logs/php-fpm.log
error_log = @{HOME}/logs/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
Expand Down
2 changes: 1 addition & 1 deletion extensions/newrelic/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _load_newrelic_info(self):
'agent', self._php_arch,
newrelic_so_name)
self._log.debug("PHP Extension [%s]", self.newrelic_so)
self.log_path = os.path.join('@{HOME}', '..', 'logs',
self.log_path = os.path.join('@{HOME}', 'logs',
'newrelic-daemon.log')
self._log.debug("Log Path [%s]", self.log_path)
self.daemon_path = os.path.join(
Expand Down
2 changes: 1 addition & 1 deletion lib/php/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def service_commands(ctx):
'-c "$HOME/php/etc"'),
'php-fpm-logs': (
'tail',
'-F $HOME/../logs/php-fpm.log')
'-F $HOME/logs/php-fpm.log')
}
else:
app = find_stand_alone_app_to_run(ctx)
Expand Down
1 change: 1 addition & 0 deletions scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from datetime import datetime
from build_pack_utils import Builder
from compile_helpers import setup_webdir_if_it_doesnt_exist
from compile_helpers import setup_log_dir


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions tests/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_compile_httpd(self):
eq_('php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y '
'"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"',
lines[1])
eq_('php-fpm-logs: tail -F $HOME/../logs/php-fpm.log',
eq_('php-fpm-logs: tail -F $HOME/logs/php-fpm.log',
lines[2])
# Check htdocs and config
self.assert_exists(self.build_dir, 'htdocs')
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_compile_nginx(self):
eq_('php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y '
'"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"',
lines[1])
eq_('php-fpm-logs: tail -F $HOME/../logs/php-fpm.log',
eq_('php-fpm-logs: tail -F $HOME/logs/php-fpm.log',
lines[2])
# Test htdocs & config
self.assert_exists(self.build_dir, 'htdocs')
Expand Down Expand Up @@ -382,7 +382,7 @@ def test_compile_httpd_custom_webdir(self):
eq_('php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y '
'"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"',
lines[1])
eq_('php-fpm-logs: tail -F $HOME/../logs/php-fpm.log',
eq_('php-fpm-logs: tail -F $HOME/logs/php-fpm.log',
lines[2])
# Check public and config
self.assert_exists(self.build_dir, 'public')
Expand Down
8 changes: 4 additions & 4 deletions tests/test_newrelic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def testShouldInstall(self):
eq_('@{HOME}/newrelic/agent/x64/newrelic-20100525.so', nr.newrelic_so)
eq_('app-name-1', nr.app_name)
eq_('JUNK_LICENSE', nr.license_key)
eq_('@{HOME}/../logs/newrelic-daemon.log', nr.log_path)
eq_('@{HOME}/logs/newrelic-daemon.log', nr.log_path)
eq_('@{HOME}/newrelic/daemon/newrelic-daemon.x64', nr.daemon_path)
eq_('@{HOME}/newrelic/daemon.sock', nr.socket_path)
eq_('@{HOME}/newrelic/daemon.pid', nr.pid_path)
Expand Down Expand Up @@ -90,7 +90,7 @@ def testShouldInstallService(self):
eq_('@{HOME}/newrelic/agent/x64/newrelic-20100525.so', nr.newrelic_so)
eq_('app-name-1', nr.app_name)
eq_('LICENSE', nr.license_key)
eq_('@{HOME}/../logs/newrelic-daemon.log', nr.log_path)
eq_('@{HOME}/logs/newrelic-daemon.log', nr.log_path)
eq_('@{HOME}/newrelic/daemon/newrelic-daemon.x64', nr.daemon_path)
eq_('@{HOME}/newrelic/daemon.sock', nr.socket_path)
eq_('@{HOME}/newrelic/daemon.pid', nr.pid_path)
Expand Down Expand Up @@ -122,7 +122,7 @@ def testShouldInstallServiceAndManual(self):
eq_('@{HOME}/newrelic/agent/x64/newrelic-20100525.so', nr.newrelic_so)
eq_('app-name-2', nr.app_name)
eq_('LICENSE2', nr.license_key)
eq_('@{HOME}/../logs/newrelic-daemon.log', nr.log_path)
eq_('@{HOME}/logs/newrelic-daemon.log', nr.log_path)
eq_('@{HOME}/newrelic/daemon/newrelic-daemon.x64', nr.daemon_path)
eq_('@{HOME}/newrelic/daemon.sock', nr.socket_path)
eq_('@{HOME}/newrelic/daemon.pid', nr.pid_path)
Expand Down Expand Up @@ -266,7 +266,7 @@ def test_compile_httpd_with_newrelic(self):
eq_('php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y '
'"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"',
lines[1])
eq_('php-fpm-logs: tail -F $HOME/../logs/php-fpm.log',
eq_('php-fpm-logs: tail -F $HOME/logs/php-fpm.log',
lines[2])

# Check htdocs and config
Expand Down
15 changes: 5 additions & 10 deletions tests/test_rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ def setUp(self):
def tearDown(self):
BaseRewriteScript.tearDown(self)

@with_setup(setup=setUp, teardown=tearDown)
def test_rewrite_no_args(self):
try:
self.run.check_output(self.rewrite,
cwd=os.path.join(self.run_dir, 'bin'),
cwd=self.run_dir,
env=self.env,
stderr=subprocess.STDOUT,
shell=True)
Expand All @@ -57,12 +56,11 @@ def test_rewrite_no_args(self):
'directory.\n', e.output)
eq_(255, e.returncode)

@with_setup(setup=setUp, teardown=tearDown)
def test_rewrite_arg_file(self):
cfg_file = os.path.join(self.cfg_dir, 'php.ini')
res = self.run.check_output("%s %s" % (self.rewrite, cfg_file),
env=self.env,
cwd=os.path.join(self.run_dir, 'bin'),
cwd=self.run_dir,
stderr=subprocess.STDOUT,
shell=True)
eq_('', res)
Expand All @@ -71,11 +69,10 @@ def test_rewrite_arg_file(self):
eq_(-1, cfgFile.find('@{HOME}'))
eq_(-1, cfgFile.find('@{TMPDIR}'))

@with_setup(setup=setUp, teardown=tearDown)
def test_rewrite_arg_dir(self):
res = self.run.check_output("%s %s" % (self.rewrite, self.cfg_dir),
env=self.env,
cwd=os.path.join(self.run_dir, 'bin'),
cwd=self.run_dir,
stderr=subprocess.STDOUT,
shell=True)
eq_('', res)
Expand All @@ -101,11 +98,10 @@ def setUp(self):
def tearDown(self):
BaseRewriteScript.tearDown(self)

@with_setup(setup=setUp, teardown=tearDown)
def test_rewrite_with_sub_dirs(self):
res = self.run.check_output("%s %s" % (self.rewrite, self.cfg_dir),
env=self.env,
cwd=os.path.join(self.run_dir, 'bin'),
cwd=self.run_dir,
stderr=subprocess.STDOUT,
shell=True)
eq_('', res)
Expand All @@ -129,11 +125,10 @@ def setUp(self):
def tearDown(self):
BaseRewriteScript.tearDown(self)

@with_setup(setup=setUp, teardown=tearDown)
def test_rewrite(self):
res = self.run.check_output("%s %s" % (self.rewrite, self.cfg_dir),
env=self.env,
cwd=os.path.join(self.run_dir, 'bin'),
cwd=self.run_dir,
stderr=subprocess.STDOUT,
shell=True)
eq_('', res)
Expand Down

0 comments on commit e94d88b

Please sign in to comment.