Hi i have added the following lines in /etc/logrotate.d/syslog-ng to make /var/log/cron rotate.
/var/log/cron {
rotate 1
size=1k
nocompress
postrotate
/bin/killall -HUP syslog-ng 2>/dev/null || true
endscript
}
After i do this, it is found that logrotation for /var/log/cron is not happening. Moreover the logrotation for other files which used to work earlier before adding this piece of code also does not work. I have included the file /etc/logrotate.d/ in /etc/logrotate.conf
Where am i going wrong ?
My original /etc/logrotate.d/syslog-ng is given below
/var/log/cmm/cmm/error.log {
rotate 5
compress
size=100k
postrotate
/usr/bin/killall -HUP syslog-ng 2> /dev/null || true
endscript
}
# ------------------- rotate and move user.log
/usr/local/data/log/user.log {
rotate 10
compress
size=1000k
missingok
}
/tmp/log/user.log {
rotate 1
nocompress
size=100k
postrotate
/usr/bin/killall -HUP syslog-ng 2> /dev/null || true
cat /tmp/log/user.log.1 >> /usr/local/data/log/user.log
endscript
}
# ------------------- rotate and move debug.log
/usr/local/data/log/debug.log {
rotate 32
compress
size=1000k
missingok
}
/tmp/log/debug.log {
rotate 1
nocompress
size=100k
postrotate
/usr/bin/killall -HUP syslog-ng 2> /dev/null || true
cat /tmp/log/debug.log.1 >> /usr/local/data/log/debug.log
endscript
}
All your other directives have /usr/bin/killall.
The cron directive has /bin/killall. Maybe that's the reason?
In any case, run
logrotate -d /path/to/your/script
And look for clues in its output.
Related
I am trying to comprehend how, if even it can be done, can I avoid subshell?
Is this the only way the code can be written or is there another way?
I tried to use braces { ... }, but it won't pass shellcheck and won't run.
is_running_interactively ()
# test if file descriptor 0 = standard input is connected to the terminal
{
[ -t 0 ]
}
is_tput_available ()
# check if tput coloring is available
{
command -v tput > /dev/null 2>&1 &&
tput bold > /dev/null 2>&1 &&
tput setaf 1 > /dev/null 2>&1
}
some_other_function ()
# so far unfinished function
{
# is this a subshell? if so, can I avoid it somehow?
( is_running_interactively && is_tput_available ) || # <-- HERE
{
printf '%b' "${2}"
return
}
...
}
It is a compound-list, and yes those commands are run in a subshell. To avoid it, use curly braces instead of parentheses:
{ is_running_interactively && is_tput_available; } || ...
Hi I've installed mediawiki 1.26.2 with the extensión Visual Editor, nodejs and parsoid, the question is that when I start parsoid, it seems every process is working right but the the configuration of parsoid and visualeditor, I can't see any editor in my wiki.
I describe below all my configurations, how I start parsoid, the processes of parsoid involved and the configurations lines in localsettings of media wiki configuration file.
/etc/init.d/parsoid2 start-end script:
#!/bin/bash
#
# chkconfig: 35 90 12
# description: Foo server
#
# Get function from functions library
#. /etc/init.d/functions
# Start the service PARSOID
SCRIPT_PATH="/usr/lib/parsoid/src/bin/server.js"
DAEMON="/usr/bin/node $SCRIPT_PATH"
DAEMON_ARGS=""
start() {
#initlog -c "echo -n Starting PARSOID server: "
ulimit -n 64000
/usr/bin/node /usr/lib/parsoid/src/bin/server.js >> /var/log/parsoid/parsoid.log 2>&1 &
### Create the lock file ###
#touch /var/lock/subsys/parsoid
success $"PARSOID server startup"
echo
}
# Restart the service PARSOID
stop() {
#initlog -c "echo -n Stopping PARSOID server: "
pkill -f server.js
### Now, delete the lock file ###
rm -f /var/lock/subsys/parsoid
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status parsoid_nodejs.sh
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
processes of parsoid involved after I run /etc/init.d/parsoid2 start
root#vscj016mlinuxserver:~# ps -ef | grep parsoid
root 2244 1 0 08:21 pts/0 00:00:00 /usr/bin/node /usr/lib/parsoid/src/bin/server.js
root 2251 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2252 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2258 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2264 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2437 2023 0 08:36 pts/0 00:00:00 grep --color=auto parsoid
root#vscj016mlinuxserver:~#
the Localsetting.js parsoid configuration file:
exports.setup = function(parsoidConfig) {
// Set your own user-agent string
// Otherwise, defaults to "Parsoid/<current-version-defined-in- package.json>"
//parsoidConfig.userAgent = "My-User-Agent-String";
// Configure Parsoid to point to your MediaWiki instance.
parsoidConfig.setMwApi({
// The "prefix" is the name given to this wiki configuration in the
// (deprecated) Parsoid v1 API.
prefix: 'localhost', // optional
// The "domain" is used for communication with Visual Editor
// and RESTBase. It defaults to the hostname portion of
// the `uri` property below, but you can manually set it
// to an arbitrary string.
domain: 'localhost', // optional
// This is the only required parameter:
// the URL of you MediaWiki API endpoint.
uri: 'http://localhost/mediawiki/api.php',
// To specify a proxy (or proxy headers) specific to this prefix
// (which overrides defaultAPIProxyURI). Alternatively, set `proxy`
// to `null` to override and force no proxying when a default proxy
// has been set.
/*
proxy: {
uri: 'http://my.proxy:1234/',
headers: { 'X-Forwarded-Proto': 'https' } // headers are optional
}
*/
});
The configuration for VisualEditor at /var/www/HTML/mediawiki/Localsettings.php:
require_once "$IP/extensions/VisualEditor/VisualEditor.php";
wfLoadExtension ( 'VisualEditor' );
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgDefaultUserOptions['minordefault'] = 1;
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgVisualEditorParsoidURL = 'http://localhost:8000';
$wgVirtualRestConfig['modules']['parsoid'] = array('url' => 'http://localhost:8000', 'domain' => 'localhost', 'prefix' => 'localhost');
$wgSessionsInObjectCache = true;
$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;
Please ensure that your parsoid version match your Visual Editor version, there is a chance that you should use old-way to configure Visual Editor:
$wgVisualEditorParsoidURL = 'http://127.0.0.1:8000';
$wgVisualEditorParsoidPrefix = 'localhost';
If you see the button "Edit source" on your pages only, make sure the Visual Editor is enabled for some name spaces in `LocalSettings.phpExample:
$wgVisualEditorNamespaces = array(NS_MAIN, NS_USER);
Source: https://www.mediawiki.org/wiki/Extension:VisualEditor#Complete_list_of_configuration_options
Check if Visual Editor is enabled in the User Preferences and you see the enabled name spaces as well
I have a runit service I use to run a rails app using unicorn.
Its restart command uses a signal (USR2) to handle a zero-downtime restart. Basically, it waits until the new process is ready before the old ones die.
This causes a very long (40 seconds) restart time, in which service myservice restart doesn't return until the end.
While I can give runit a longer timeout (which I already do), I want to make this restart a fire-and-forget kind of action so it'll return instantly (or after the USR2 signal was fired, but without waiting for it to complete.
The entire logic is taken from multiple blog posts about zero-downtime rails deployments with unicorn restarts:
https://gist.github.com/czarneckid/4639793
https://gist.github.com/JeanMertz/8996796
https://nulogy.com/who-we-are/company-blog/articles/zero-downtime-deployments-with-chef-nginx-and-unicorn/
This is the runit script (generated by chef):
#!/bin/bash
#
# This file is managed by Chef, using the <%= node.name %> cookbook.
# Editing this file by hand is highly discouraged!
#
exec 2>&1
#
# Since unicorn creates a new pid on restart/reload, it needs a little extra
# love to manage with runit. Instead of managing unicorn directly, we simply
# trap signal calls to the service and redirect them to unicorn directly.
#
RUNIT_PID=$$
APPLICATION_NAME=<%= #options[:application_name] %>
APPLICATION_PATH=<%= File.join(#options[:path], 'current') %>
BUNDLE_CMD="<%= #options[:bundle_command] ? "#{#options[:bundle_command]} exec" : '' %>"
UNICORN_CMD=<%= #options[:unicorn_command] ? #options[:unicorn_command] : 'unicorn' %>
UNICORN_CONF=<%= #options[:unicorn_config_path] ? #options[:unicorn_config_path] : File.join(#options[:path], 'current', 'config', 'unicorn.rb') %>
RAILS_ENV=<%= #options[:rails_env] %>
CUR_PID_FILE=<%= #options['pid'] ? #options['pid'] : File.join(#options[:path], 'current', 'shared', 'pids', "#{#options[:application_name]}.pid") %>
ENV_PATH=<%= #options[:env_dir] %>
OLD_PID_FILE=$CUR_PID_FILE.oldbin
echo "Runit service restarted (PID: $RUNIT_PID)"
function is_unicorn_alive {
set +e
if [ -n $1 ] && kill -0 $1 >/dev/null 2>&1; then
echo "yes"
fi
set -e
}
if [ -e $OLD_PID_FILE ]; then
OLD_PID=$(cat $OLD_PID_FILE)
echo "Old master detected (PID: $OLD_PID), waiting for it to quit"
while [ -n "$(is_unicorn_alive $OLD_PID)" ]; do
sleep 5
done
fi
if [ -e $CUR_PID_FILE ]; then
CUR_PID=$(cat $CUR_PID_FILE)
if [ -n "$(is_unicorn_alive $CUR_PID)" ]; then
echo "Detected running Unicorn instance (PID: $CUR_PID)"
RUNNING=true
fi
fi
function start {
unset ACTION
if [ $RUNNING ]; then
restart
else
echo 'Starting new unicorn instance'
cd $APPLICATION_PATH
exec chpst -e $ENV_PATH $BUNDLE_CMD $UNICORN_CMD -c $UNICORN_CONF -E $RAILS_ENV
sleep 3
CUR_PID=$(cat $CUR_PID_FILE)
fi
}
function stop {
unset ACTION
echo 'Initializing graceful shutdown'
kill -QUIT $CUR_PID
while [ -n "$(is_unicorn_alive $CUR_PID)" ]; do
echo '.'
sleep 2
done
echo 'Unicorn stopped, exiting Runit process'
kill -9 $RUNIT_PID
}
function restart {
unset ACTION
echo "Restart request captured, swapping old master (PID: $CUR_PID) for new master with USR2"
kill -USR2 $CUR_PID
sleep 2
echo 'Restarting Runit service to capture new master PID'
exit
}
function alarm {
unset ACTION
echo 'Unicorn process interrupted'
}
trap 'ACTION=stop' STOP TERM KILL
trap 'ACTION=restart' QUIT USR2 INT
trap 'ACTION=alarm' ALRM
[ $RUNNING ] || ACTION=start
if [ $ACTION ]; then
echo "Performing \"$ACTION\" action and going into sleep mode until new signal captured"
elif [ $RUNNING ]; then
echo "Going into sleep mode until new signal captured"
fi
if [ $ACTION ] || [ $RUNNING ]; then
while true; do
[ "$ACTION" == 'start' ] && start
[ "$ACTION" == 'stop' ] && stop
[ "$ACTION" == 'restart' ] && restart
[ "$ACTION" == 'alarm' ] && alarm
sleep 2
done
fi
This is a super weird way to use Runit, move your reload logic to the control/h script and use sv hup (or since it doesn't seem to be anything more than sending USR2 sv 2). The main run script shouldn't be involved.
Logstash service doesn't want to read my conf file in /etc/logstash/conf.d/.
Service is running all the time.
For example:
...
output {
stdout { codec => rubydebug }
file { path => "/home/vagrant/LOGSTASH_TEST.txt" }
}
And nothing is added to the file.
But when I'm running bin/logstash -f /etc/logstash/conf.d/myconfig.conf — everything is fine.
/etc/init.d/logstash is looking good:
LS_CONF_DIR=/etc/logstash/conf.d
...
program=/opt/logstash/bin/logstash
args="agent -f ${LS_CONF_DIR} -l ${LS_LOG_FILE} ${LS_OPTS}"
What could be the problem?
Try changing /etc/init.d/logstash to:
LS_CONF_DIR=/etc/logstash/conf.d
LS_CONF_FILE=myconfig.conf
...
program=/opt/logstash/bin/logstash
args="agent -f ${LS_CONF_DIR}/${LS_CONF_FILE} -l ${LS_LOG_FILE} ${LS_OPTS}"
Can I do This start up service below, there are no errors showing once run, but the server script below does not run!
ln /lib/systemd/aquarium.service aquarium.service
systemctl daemon-reload
systemctl enable aquarium.service
systemctl start aquarium.service
thanks
aquarium.service:
[Unit]
Description=Start aquarium server
[Service]
WorkingDirectory=/home/root/python/code/aquarium/
ExecStart=/bin/bash server.* start
KillMode=process
[Install]
WantedBy=multi-user.target
here is the server.sh script
#!/bin/bash
PID=""
function get_pid {
PID=`pidof python ./udpthread.py`
}
function stop {
get_pid
if [ -z $PID ]; then
echo "server is not running."
exit 1
else
echo -n "Stopping server.."
kill -9 $PID
sleep 1
echo ".. Done."
fi
}
function start {
get_pid
if [ -z $PID ]; then
echo "Starting server.."
./udpthread.py &
get_pid
echo "Done. PID=$PID"
else
echo "server is already running, PID=$PID"
fi
}
function restart {
echo "Restarting server.."
get_pid
if [ -z $PID ]; then
start
else
stop
sleep 5
start
fi
}
function status {
get_pid
if [ -z $PID ]; then
echo "Server is not running."
exit 1
else
echo "Server is running, PID=$PID"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
Try using "Type=forking" and use complete filename.
[Unit]
Description=Start aquarium server
[Service]
WorkingDirectory=/home/root/python/code/aquarium/
Type=forking
ExecStart=/bin/bash server.sh start
KillMode=process
[Install]
WantedBy=multi-user.target
if it not work, post output of this command:
# journalctl -u aquarium.service