After my server crashed i am unable to start uWSGI again, and keep getting following errors on unlink() and bind().
I start my service as root, so it makes it even more strange.
Sun Nov 16 15:25:24 2014 - *** Starting uWSGI 1.2.3-debian (64bit) on [Sun Nov 16 15:25:24 2014] ***
Sun Nov 16 15:25:24 2014 - compiled with version: 4.7.2 on 06 July 2013 12:20:09
Sun Nov 16 15:25:24 2014 - detected number of CPU cores: 1
Sun Nov 16 15:25:24 2014 - current working directory: /
Sun Nov 16 15:25:24 2014 - writing pidfile to /run/uwsgi/app/myserver_dev/pid
Sun Nov 16 15:25:24 2014 - detected binary path: /usr/bin/uwsgi-core
Sun Nov 16 15:25:24 2014 - setgid() to 33
Sun Nov 16 15:25:24 2014 - setuid() to 33
Sun Nov 16 15:25:24 2014 - writing pidfile to /var/www/servers/myserver/development/logs/myserver.pid
Sun Nov 16 15:25:24 2014 - your memory page size is 4096 bytes
Sun Nov 16 15:25:24 2014 - detected max file descriptor number: 1024
Sun Nov 16 15:25:24 2014 - lock engine: pthread robust mutexes
Sun Nov 16 15:25:24 2014 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/myserver_dev/socket fd 3
Sun Nov 16 15:25:24 2014 - unlink(): Permission denied [socket.c line 75]
Sun Nov 16 15:25:24 2014 - bind(): Address already in use [socket.c line 107]
nginx servers:
server {
access_log /var/www/servers/example/development/logs/nginx_access.log;
error_log /var/www/servers/example/development/logs/nginx_error.log;
listen 8181;
server_name example.com;
charset utf-8;
}
server {
listen 80;
server_name *.example.com;
return 301 http://example.com$request_uri;
}
server {
access_log /var/www/servers/example/production/logs/nginx_access.log;
error_log /var/www/servers/example/production/logs/nginx_error.log;
listen 80;
server_name example.com;
charset utf-8;
}
server {
listen 7777;
server_name example.com;
charset utf-8;
root /var/www/servers/phpmyadmin;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
location ~ .php$ {
allow 2.110.234.34;
deny all;
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
uWSGI config development:
[uwsgi]
master = true
workers = 2
socket = /var/www/servers/example/development/sockets/example.sock
chmod-socket = 666
log-date = true
uid = www-data
gid = www-data
chdir = /var/www/servers/example/development/webapp
wsgi-file = /var/www/servers/example/development/webapp/webapp/wsgi.py
virtualenv = /var/www/servers/example/development/env
vacuum = true
env = DJANGO_SETTINGS_MODULE=webapp.settings
pidfile2 = /var/www/servers/example/development/logs/example.pid
uWSGI config production
[uwsgi]
master = true
workers = 2
socket = /var/www/servers/example/production/sockets/example.sock
chmod-socket = 666
log-date = true
uid = www-data
gid = www-data
chdir = /var/www/servers/example/production/webapp
wsgi-file = /var/www/servers/example/production/webapp/webapp/wsgi.py
virtualenv = /var/www/servers/example/production/env
vacuum = true
env = DJANGO_SETTINGS_MODULE=webapp.settings
pidfile2 = /var/www/servers/example/production/logs/example.pid
Albeit you run the server as root it drops privileges to 33 (presumibly www-data). This user (33) must own the right to remove /var/www/servers/example/production/sockets/example.sock.
Probably the crash corrupted the inode that now has wrong attributes. Fix them and it should work again.
Related
There is an embedded system, and it provides functions in a struct of platform_driver:
static struct platform_driver infinity_wdt_driver = {
.probe = infinity_wdt_probe,
.remove = infinity_wdt_remove,
.shutdown = infinity_wdt_shutdown,
.driver = {
.owner = THIS_MODULE,
.name = "infinity-wdt",
.of_match_table = ms_watchdog_of_match_table,
},
};
module_platform_driver(infinity_wdt_driver);
In the infinity_wdt_probe it calls devm_kzalloc and devm_ioremap_resource:
static int infinity_wdt_probe(struct platform_device *pdev) {
...
wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
...
wdt->reg_base = devm_ioremap_resource(&pdev->dev, res);
...
}
How shall I utilize this driver? Do I need to write some C code, or Linux provides some standard way through filesystem for controlling this?
In the filesystem there is a directory under /sys/bus/platform/drivers/infinity-wdt, but it contains only a few files:
# ls -l
total 0
lrwxrwxrwx 1 root root 0 Nov 16 20:23 1f006000.watchdog -> ../../../../devices/soc0/soc/1f006000.watchdog
--w------- 1 root root 4096 Nov 16 20:23 bind
--w------- 1 root root 4096 Nov 16 20:23 uevent
--w------- 1 root root 4096 Nov 16 20:23 unbind
Is it somehow possible to use the driver with this filesystem above?
Some extra info: 1f006000.watchdog is a symlink to a directory which contains these:
# ls -l
total 0
lrwxrwxrwx 1 root root 0 Nov 16 20:23 driver -> ../../../../bus/platform/drivers/infinity-wdt
-rw-r--r-- 1 root root 4096 Nov 16 20:23 driver_override
-r--r--r-- 1 root root 4096 Nov 16 20:23 modalias
lrwxrwxrwx 1 root root 0 Nov 16 20:23 of_node -> ../../../../firmware/devicetree/base/soc/watchdog
lrwxrwxrwx 1 root root 0 Nov 16 20:23 subsystem -> ../../../../bus/platform
-rw-r--r-- 1 root root 4096 Nov 16 20:23 uevent
This is the kernel log:
# cat /var/log/messages | grep -i watchdog
Jan 1 04:00:02 kernel: [WatchDog]infinity_wdt_probe
Jan 1 04:00:02 kernel: [WatchDog]infinity_wdt_set_heartbeat
Jan 1 04:00:04 kernel: [WatchDog]infinity_wdt_start
Jan 1 04:00:04 kernel: [WatchDog] infinity_wdt_ping tmr_margin=a ^M
Jan 1 04:00:04 kernel: watchdog: watchdog0: watchdog did not stop!
Jan 1 04:00:04 kernel: [WatchDog] infinity_wdt_ping tmr_margin=a ^M
Jan 1 04:00:04 kernel: [WatchDog]infinity_wdt_set_timeout=60
Jan 1 04:00:04 kernel: [WatchDog]infinity_wdt_set_timeout data=3c ^M
Jan 1 04:00:04 kernel: [WatchDog] infinity_wdt_ping tmr_margin=3c ^M
Jan 1 04:00:04 kernel: [WatchDog] infinity_wdt_ping tmr_margin=3c ^M
Nov 16 21:03:11 kernel: [WatchDog] infinity_wdt_ping tmr_margin=3c ^M
Nov 16 21:03:41 kernel: [WatchDog] infinity_wdt_ping tmr_margin=3c ^M
"Platform" driver means driver that doesn't fit into other standard subsystem (e.g. USB, I2C, etc). In this case it's a watchdog driver, which is apparently supposed to reboot embedded system if it's not responsive.
Entries in sysfs are standard bookkeeping entries, automatically created for any driver by kernel.
Since driver contains "of_match_table", it implies that it must be correctly specified in the device tree. Given it generally works and has no other explicit interfaces (e.g. procfs, sysfs), this should be enough to enable it.
You might also check if corresponding /dev/watchdog* is created by this driver. If so, standard userspace watchdog can be used by specified this /dev/watchdog* file in its config file.
The same job can be executed as root, but it can't execute as a standard user.
Is it permission problem or I need to change anything, I have no idea on it.
Thanks
SunOS 5.10 Generic_150400-30 sun4v sparc SUNW,SPARC-Enterprise-T5120
Command:
1) login as a root
2) crontab -l
* * * * * /usr/bin/date > /tmp/root.log
3) /tmp/root.log is here
1) login as a Non-root user
2) crontab -l
* * * * * /usr/bin/date > /tmp/non-root.log
3) /tmp/non-root.log is not here
The following permissions are OK for the binary file date
-bash-3.2# ls -l /usr/bin/date
-r-xr-xr-x 1 root bin 11056 Jan 22 2005 /usr/bin/date
-bash-3.2#
If the permissions are OK check your cron log on /var/cron/log file
-bash-3.2# tail /var/cron/log
< root 24592 c Fri Oct 20 18:50:21 2017
> CMD: /usr/bin/date > /tmp/non-root.log
> user 25192 c Fri Oct 20 18:51:00 2017
< user 25192 c Fri Oct 20 18:51:00 2017
> CMD: /scripts/collectdata.sh > /dev/null 2>&1
> root 25769 c Fri Oct 20 18:52:00 2017
< root 25769 c Fri Oct 20 18:52:00 2017
> CMD: /scripts/collectdata.sh > /dev/null 2>&1
> root 26853 c Fri Oct 20 18:54:00 2017
< root 26853 c Fri Oct 20 18:54:00 2017
-bash-3.2#
Thanks all, I finally found out the issue.
The reason is that non-root account is locked out, I think it maybe someone did many failure attempt which make this locked.
After I passwd -u "Account", the job can be run as expected. Thanks~
I'm working with Yocto to create an embedded linux distribution for an ARM device (i.MX 6Quad Processors).
I've configured the list of desired locales with the variable:
IMAGE_LINGUAS = "de-de fr-fr en-gb en-gb.iso-8859-1 en-us en-us.iso-8859-1 zh-cn"
As result I've obtained a file systems that contains the following folders:
root#lam_icu:/usr/lib/locale# cd /usr/share/locale/
root#lam_icu:/usr/share/locale# ls -la
total 0
drwxr-xr-x 6 root root 416 Nov 17 2016 .
drwxr-xr-x 30 root root 2056 Nov 17 2016 ..
drwxr-xr-x 4 root root 296 Nov 17 2016 de
drwxr-xr-x 3 root root 232 Nov 17 2016 en_GB
drwxr-xr-x 4 root root 296 Nov 17 2016 fr
drwxr-xr-x 4 root root 296 Nov 17 2016 zh_CN
and:
root#lam_icu:/usr/share/locale# cd /usr/lib/locale/
root#lam_icu:/usr/lib/locale# ls -la
total 0
drwxr-xr-x 9 root root 640 Mar 13 2017 .
drwxr-xr-x 32 root root 40000 Mar 13 2017 ..
drwxr-xr-x 3 root root 1016 Mar 13 2017 de_DE
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_GB
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_GB.ISO-8859-1
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_US
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_US.ISO-8859-1
drwxr-xr-x 3 root root 1016 Mar 13 2017 fr_FR
drwxr-xr-x 3 root root 1016 Mar 13 2017 zh_CN
Which is the encoding of all non ISO-8859-1 locales? Can I assume that "en_GB" or "en_US" use the UTF-8 encoding?
I've tried to open the "LC_IDENTIFICATION" file, the result is:
Hc�������������cEnglish locale for the USAFree Software
Foundation,
Inc.http://www.gnu.org/software/libc/bug-glibc-locales#gnu.orgEnglishUSA1.02000-06-24en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000UTF-8
At the end of the file there is something that recalls "UTF-8". Is this enough to assume that the encoding is UTF-8?
How to check if a locale is UTF-8?
LC_IDENTIFICATION doesn't tell you much:
LC_IDENTIFICATION - this is not a user-visible category, it contains information about the locale itself and is rarely useful for users or developers (but is listed here for completeness sake).
You'd have to look at the complete set of files.
There appears to be no standard command-line utility for doing this, but there is a runtime call (added a little later than the original locale functions). Here is a sample program which illustrates the function nl_langinfo:
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
int
main(int argc, char **argv)
{
int n;
for (n = 1; n < argc; ++n) {
if (setlocale(LC_ALL, argv[n]) != 0) {
char *code = nl_langinfo(CODESET);
if (code != 0)
printf("%s ->%s\n", argv[n], code);
else
printf("?%s (nl_langinfo)\n", argv[n]);
} else {
printf("? %s (setlocale)\n", argv[n]);
}
}
return 0;
}
and some output, e.g., by foo $(locale -a):
aa_DJ ->ISO-8859-1
aa_DJ.iso88591 ->ISO-8859-1
aa_DJ.utf8 ->UTF-8
aa_ER ->UTF-8
aa_ER#saaho ->UTF-8
aa_ER.utf8 ->UTF-8
aa_ER.utf8#saaho ->UTF-8
aa_ET ->UTF-8
aa_ET.utf8 ->UTF-8
af_ZA ->ISO-8859-1
af_ZA.iso88591 ->ISO-8859-1
af_ZA.utf8 ->UTF-8
am_ET ->UTF-8
am_ET.utf8 ->UTF-8
an_ES ->ISO-8859-15
an_ES.iso885915 ->ISO-8859-15
an_ES.utf8 ->UTF-8
ar_AE ->ISO-8859-6
ar_AE.iso88596 ->ISO-8859-6
ar_AE.utf8 ->UTF-8
ar_BH ->ISO-8859-6
ar_BH.iso88596 ->ISO-8859-6
The directory names you're referring to are often (but not required) to be the same as encoding names. That is the assumption made in the example program. There was a related question in How to get terminal's Character Encoding, but it has no useful answers. One is interesting though, since it asserts that
locale charmap
will give the locale encoding. According to the standard, that's not necessarily so:
The command locale charmap gives the name used in localedef -f
However, localedef attaches no special meaning to the name given in the -f option.
localedef has a different option -u which identifies the codeset, but locale (in the standard) mentions no method for displaying this information.
As usual, implementations may (or may not) treat unspecified features in different ways. The GNU C library's documentation differs in some respects from the standard (see locale and localedef), but offers no explicit options for showing the codeset name.
I try to build a short ocaml event example. But when I compile, the error in the title appears.
The question of: unbound module Event error when compiling Ocaml game was not helpful for me.
The system is Kubuntu 14.04 and I installed ocaml over aptitude, so installed packages are:
camlp4, ledit, libfindlib-ocaml, libfindlib-ocaml-dev, liboasis-ocaml, liboasis-ocaml-dev, libodn-ocaml, libodn-ocaml-dev, libtype-conv-camlp4-dev, oasis, ocaml, ocaml-base, ocaml-base-nox, ocaml-compiler-libs, ocaml-doc, ocaml-findlib, ocaml-interp, ocaml-native-compilers, ocaml-nox
The OCaml compiler is version 4.01.0
Here is my short test program.
open Thread;;
open Event;;
let chan = Event.new_channel();;
let a () =
Printf.printf "A waiting...\n";;
let sigRX = Event.receive chan in
Printf.printf "A received over channel\n";
let v = Event.sync sigRx in
Printf.printf "A running\n";
Printf.printf "A done!\n";;
let b () =
Thread.delay 0.8
Printf.printf "B sending...\n";;
let sigTX = Event.send "wake up" in
Event.sync sigTX;
Printf.printf "B done!\n";;
let t_a = Thread.create a ();;
let t_b = Thread.create b ();;
I tried to compile this single file (test.ml) with:
ocamlc -thread unix.cma threads.cma test.ml
The response is:
File "test.ml", line 2, characters 0-10:
Error: Unbound module Event
I googled, found some "thread-using-tips" like: http://caml.inria.fr/pub/docs/manual-ocaml/libthreads.html#c%3Athreads
In /usr/lib/ocaml is an threads folder and an thread.mli. Inside the threads folder there are this files:
-rw-r--r-- 1 root root 487 Jan 2 2014 condition.cmi
-rw-r--r-- 1 root root 487 Jan 2 2014 condition.cmx
-rw-r--r-- 1 root root 1203 Jan 2 2014 event.cmi
-rw-r--r-- 1 root root 1867 Jan 2 2014 event.cmx
-rw-r--r-- 1 root root 421 Jan 2 2014 mutex.cmi
-rw-r--r-- 1 root root 407 Jan 2 2014 mutex.cmx
-rw-r--r-- 1 root root 1859 Jan 2 2014 thread.cmi
-rw-r--r-- 1 root root 1308 Jan 2 2014 thread.cmx
-rw-r--r-- 1 root root 62778 Jan 2 2014 threads.a
-rw-r--r-- 1 root root 47047 Jan 2 2014 threads.cma
-rw-r--r-- 1 root root 1258 Jan 2 2014 threads.cmxa
-rw-r--r-- 1 root root 4145 Jan 2 2014 threadUnix.cmi
-rw-r--r-- 1 root root 1515 Jan 2 2014 threadUnix.cmx
What am I missing? I assume, that the Event is packed in Thread Module?
This command line works for me to get past the unbound module problem.
$ ocamlc -I +threads -c test.ml
There are errors in your code, but I imagine you'll know how to fix them.
This full command line will probably work, but I can't be sure because of the errors:
$ ocamlc -thread -I +threads unix.cma threads.cma test.ml
(There are some higher-level tools for building OCaml programs that you might want to learn about at some point.)
I am a newbie as far as node.js is concerned.I wrote the following code to pipeline two linux commands.
This is my nodejs code:
var spawn = require('child_process').spawn,
ls = spawn('ls',['-lh','/usr']),
grep = spawn('grep',['bin']);
/*
ls.stdout.on('data',function(data){
console.log('stdout: '+data);
});
*/
ls.stdout.on('data',function(data){
console.log(""+data);
grep.stdin.write(data);
});
ls.stderr.on('data',function(data){
console.log('stderr: '+data);
});
ls.on('exit',function(code){
console.log('Exit code '+code);
grep.stdin.end();
})
// ------------------------------------
grep.stdout.on('data',function(data){
console.log('stdout: '+data);
});
grep.stderr.on('data',function(data){
console.log('stderr: '+data);
});
Now this code fails sometimes and runs sometimes.I'm getting confused now.
When it fails,it says:
Exit code 0
total 160K
drwxr-xr-x 2 root root 68K Oct 12 12:54 bin
drwxr-xr-x 2 root root 4.0K Jun 20 19:58 games
drwxr-xr-x 54 root root 4.0K Sep 24 17:52 include
drwxr-xr-x 252 root root 44K Oct 2 21:53 lib
drwxr-xr-x 10 root root 4.0K Apr 28 19:16 local
drwxr-xr-x 2 root root 12K Sep 18 15:51 sbin
drwxr-xr-x 362 root root 12K Sep 28 17:58 share
drwxr-xr-x 5 root root 4.0K Jul 7 23:39 src
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._write (net.js:517:19)
at Socket.write (net.js:509:15)
at Socket.<anonymous> (/home/rajat/nodexperiments/full-spawn.js:13:13)
at Socket.EventEmitter.emit (events.js:88:17)
at Pipe.onread (net.js:395:14)
And when it runs,it says:
total 160K
drwxr-xr-x 2 root root 68K Oct 12 12:54 bin
drwxr-xr-x 2 root root 4.0K Jun 20 19:58 games
drwxr-xr-x 54 root root 4.0K Sep 24 17:52 include
drwxr-xr-x 252 root root 44K Oct 2 21:53 lib
drwxr-xr-x 10 root root 4.0K Apr 28 19:16 local
drwxr-xr-x 2 root root 12K Sep 18 15:51 sbin
drwxr-xr-x 362 root root 12K Sep 28 17:58 share
drwxr-xr-x 5 root root 4.0K Jul 7 23:39 src
Exit code 0
stdout: drwxr-xr-x 2 root root 68K Oct 12 12:54 bin
drwxr-xr-x 2 root root 12K Sep 18 15:51 sbin
Any Ideas?
This is quite clearly a race condition, because node.js is a highly parallel environment you have found a really nice example to demonstrate this.
ls.on('exit',function(code){
console.log('Exit code '+code);
grep.stdin.end();
})
ls fires the above event, before it has finished writing to grep, and then closes the socket that's being used to communicate. The hint your output gives you is that the exit(0) message coming from ls appears once at the top of the output, and once just above the error message.
You shouldn't be closing grep's stdin channel here.
But what about using .exec() instead of spawn on a bash script that does something like
#/bin/bash mybashscript
ls $1 | grep bin
and then using the JavaScript closure, such as
child = exec('mybashscript',['-lh','/usr']
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
With the events your code ordering is more difficult to read.