RaspberryPI / NGINX bootscript not working[solved]

SBFspot protocol http://sbfspot.codeplex.com/
Post Reply
ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

RaspberryPI / NGINX bootscript not working[solved]

Post by ankn99 » Thu Sep 01, 2016 1:20 pm

Hi,
as requestet new Topic :D

The following Problem:

when I do a

sudo -u root /usr/bin/curl http://localhost/scripts/boot123s.php

no Errors Show up, when I look for the process:

ps xa | grep 123
22267 ? S 0:06 /usr/bin/php 123solar.php
24195 pts/2 S+ 0:00 grep --color=auto 123

It is there ....

The Mainpage at the Webserver tells me for both converter 0W even after a Minute ...

when I take a look at the admin page I see the Switch turned on (green)

When I now turn it off and right after this on, the FrontPage Shows me the actual producing energy ..

when I do a ps xa | grep 123

I see, the 123solar.php was restarted (new PID)

26536 ? S 0:00 php ../scripts/123solar.php
26774 pts/2 S+ 0:00 grep --color=auto 123

with this I could live, but the Problem will be back, when I have a power failure ....

I dont know if this Problem belongs together, but ... after 2 or 3 days, the script doesn't get any data from the converters anymore ....

I would like to do a restart every night, but as I wrote above, it isn't starting automaticly ...

I'm using a RaspberryPI 2B with raspbian 8 (jessie)
nginx version: nginx/1.6.2

#php -v
PHP 5.6.24-0+deb8u1 (cli) (built: Jul 27 2016 00:06:04)

#php5-fpm -v
PHP 5.6.24-0+deb8u1 (fpm-fcgi) (built: Jul 27 2016 00:56:03)

SBFspot V3.3.1
Last edited by ankn99 on Fri Sep 02, 2016 9:21 am, edited 1 time in total.

jeanmarc
Posts: 1564
Joined: Thu Aug 29, 2013 7:16 am

Re: RaspberryPI / NGINX bootscript not working

Post by jeanmarc » Thu Sep 01, 2016 3:11 pm

Do you see 'Starting 123Solar on boot' on event file ?
Also see that topic for hints.

ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

Re: RaspberryPI / NGINX bootscript not working

Post by ankn99 » Fri Sep 02, 2016 6:16 am

Hi,

yes I do.

I even changed the script to get some Status Information posted in to the logfile:

01.09.2016 20:16:20 Starting 123Solar on boot
****** OUtPUT from 'set' ******
HOME='/var/www'
IFS='
'
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
PPID='31586'
PS1='$ '
PS2='> '
PS4='+ '
PWD='/var/www/html/scripts'
USER='www-data'
***** OUTPUT from 'whereis php' *****
php is /usr/bin/php
****** Here I stoped the Daemon
01.09.2016 20:17:33 Stopping 123Solar
***** And here I started the daemon again ...
01.09.2016 20:17:35 Starting 123Solar

This is from yesterday, here I try it today too:

Here I restart it from the CMDLine:

# sudo -u root /usr/bin/curl -v http://localhost/scripts/boot123s.php
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 80 failed: Verbindungsaufbau abgelehnt
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /scripts/boot123s.php HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.6.2 is not blacklisted
< Server: nginx/1.6.2
< Date: Fri, 02 Sep 2016 05:07:35 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
<
* Connection #0 to host localhost left intact

********** Log-File:

02.09.2016 07:07:35 Starting 123Solar on boot
***** OUTPUT from 'set' *****
HOME='/var/www'
IFS='
'
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
PPID='14014'
PS1='$ '
PS2='> '
PS4='+ '
PWD='/var/www/html/scripts'
USER='www-data'
***** OUTPUT from 'whereis php' *****
php is /usr/bin/php

as expected, rigt after this, at the FrontPage, the Values Drops to Zero ...
now I Need to enter the Admin Interface and

"STOP the Logger"
02.09.2016 07:07:53 Stopping 123Solar
"and START the Logger"
02.09.2016 07:07:56 Starting 123Solar
Now everything is back to normal ...

I didn't changed the Port from the Webserver its still port 80 !

since there it seems no Problem with the commandline and the php-interpreter itself, I#ll get rid of the set and whereis command in the startscript !

ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

Re: RaspberryPI / NGINX bootscript not working

Post by ankn99 » Fri Sep 02, 2016 6:37 am

Here is, what my /etc/Hosts file Looks like:

Code: Select all

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.1.1       raspberrypi1
Here you can see the proccesses that are listening to http(port 80)

Code: Select all

lsof -i | grep LISTEN | grep nginx
nginx       716     root    6u  IPv4    11558      0t0  TCP *:http (LISTEN)
nginx       717 www-data    6u  IPv4    11558      0t0  TCP *:http (LISTEN)
nginx       718 www-data    6u  IPv4    11558      0t0  TCP *:http (LISTEN)
nginx       719 www-data    6u  IPv4    11558      0t0  TCP *:http (LISTEN)
nginx       720 www-data    6u  IPv4    11558      0t0  TCP *:http (LISTEN)
NGINX-Config:

/etc/nginx/nginx.conf:

Code: Select all

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##
        
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}
/etc/nginx/php.conf

Code: Select all

#############################################################

fastcgi_intercept_errors on;
# this will allow Nginx to intercept 4xx/5xx error codes
# Nginx will only intercept if there are error page rules defined
# -- This is better placed in the http {} block as a default
# -- so that in the case of wordpress, you can turn it off specifically
# -- in that virtual host's server block

location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# A handy function that became available in 0.7.31 that breaks down
# The path information based on the provided regex expression
# This is handy for requests such as file.php/some/paths/here/
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
#############################################################
/etc/nginx/sites-available

Code: Select all

server {
                listen 80;
                server_name raspberrypi1 myname.dyndns-addr.org;
                root /var/www/html;
                index  index.html  index.php;

location / {
 try_files $uri $uri/ /index.php?$args;
}

                ## Only allow these request methods ##
                        #if ($request_method !~ ^(GET|HEAD|POST)$ ) {
                        # return 444;
                        #}

                        # Http authentication uncomment thoses lines
                        location  /admin {
                          index index.php;
                          auth_basic            "Restricted";
                          auth_basic_user_file  /var/www/html/config/.htpasswd;
                        }

                #!!! IMPORTANT !!! We need to hide the password file from prying eyes
                        location ~ /\. { deny  all; }
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
                fastcgi_index index.php;
                include fastcgi_params;
        }


                }
The rest of config-files (php5-fpm etc.) is pretty much Standard !

jeanmarc
Posts: 1564
Joined: Thu Aug 29, 2013 7:16 am

Re: RaspberryPI / NGINX bootscript not working

Post by jeanmarc » Fri Sep 02, 2016 6:50 am

recap : 123solar start with curl .. boot123s.php but the values goes to null after a while.
Then, you had to stop/start 123s via manually. Is that correct ?
If so, it's probably because you com process is stuck/lock. Check when it happen if you have a dead or several SBF processes running.

ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

Re: RaspberryPI / NGINX bootscript not working

Post by ankn99 » Fri Sep 02, 2016 8:29 am

No, is not correct :cry:

This is during normal Operation:

Code: Select all

# ps xa | grep 123
15845 ?        S      0:27 php ../scripts/123solar.php
29830 ?        S      0:00 sh -c timeout --kill-after=15s 10s SBFspot -finq -q -123s=DATA -cfg/var/www/html/config/SBFspot_1.cfg -nosql
29831 ?        S      0:00 timeout --kill-after=15s 10s SBFspot -finq -q -123s=DATA -cfg/var/www/html/config/SBFspot_1.cfg -nosql
29832 ?        S      0:00 SBFspot -finq -q -123s=DATA -cfg/var/www/html/config/SBFspot_1.cfg -nosql
These are the proccesses right after I did : sudo -u root /usr/bin/curl http://localhost/scripts/boot123s.php

Code: Select all

# ps xa | grep 123
30057 ?        S      0:05 /usr/bin/php 123solar.php


at the same time, the at the FrontPage, everything goes down to 0 for both Inverters.

then I go to the admin Interface turn the Switch (the green big one) off into red and right after this back on ...
a second later, the FrontPage Shows working energy-meters .... and the processtable is back to normal again ....

ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

Re: RaspberryPI / NGINX bootscript not working

Post by ankn99 » Fri Sep 02, 2016 8:37 am

my stomeck tells me, there must be a different between the ways, the 123solar.php is called !

at the proccess table during normal Operation (switched on and of per Webinterface)

213solar.php seems to be called from the admin Directory i think ....

Code: Select all

php ../scripts/123solar.php
If it is called per shellscript it Looks like, the call was from the same Directory where the boot123s.php lives:

Code: Select all

/usr/bin/php 123solar.php
And there I think the Problem is ...

wait a second, I#ll try something !!!

ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

Re: RaspberryPI / NGINX bootscript not working

Post by ankn99 » Fri Sep 02, 2016 9:21 am

Jepp, I found the Problem ....

It is the Version of SBFspot .....

before the update, it was enough when the following files where hanging at a central Directory, don't rember but it was something like /usr/local/anywhere .....

But since Version: V3.3.1, the Programm Looks for the following files inside the working (calling) Directory:

Code: Select all

260483 -rwxr-xr-x 1 www-data www-data  35855 Aug 16 08:57 date_time_zonespec.csv
260472 -rwxr-xr-x 1 www-data www-data 194295 Aug 16 08:57 TagListDE-DE.txt
260473 -rwxr-xr-x 1 www-data www-data 186428 Aug 16 08:57 TagListEN-US.txt
260475 -rwxr-xr-x 1 www-data www-data 196725 Aug 16 08:57 TagListES-ES.txt
260478 -rwxr-xr-x 1 www-data www-data 200214 Aug 16 08:57 TagListFR-FR.txt
260479 -rwxr-xr-x 1 www-data www-data 194914 Aug 16 08:57 TagListIT-IT.txt
260482 -rwxr-xr-x 1 www-data www-data 189000 Aug 16 08:57 TagListNL-NL.txt
[code]

when I first started the upgrade, I've had the Problem, that the 123solar was telling me about Connection Problems.

I tried to call the Program manualy like this:
[code]SBFspot -finq -q -123s=DATA -cfg/var/www/html/config/SBFspot_1.cfg -nosql
and it bumped out with an error:
Unable to open 'date_time_zonespec.csv'

So I copied the above mentioned files into the admin Directory -> running !

Now that we where talking about the Startup Problems, it helped me remembering the Problem I've had before ....

thank a lot, it seems to work now :lol:

jeanmarc
Posts: 1564
Joined: Thu Aug 29, 2013 7:16 am

Re: RaspberryPI / NGINX bootscript not working[solved]

Post by jeanmarc » Fri Sep 02, 2016 10:23 am

Duh :mrgreen: It might be good to request SBF to look the 'date_time_zonespec.csv' file elsewhere. ;)

ankn99
Posts: 14
Joined: Thu Aug 25, 2016 6:59 am

Re: RaspberryPI / NGINX bootscript not working[solved]

Post by ankn99 » Tue Sep 06, 2016 8:08 am

Hi,

123solar survived a few newstarts at midnight ....
I think Reboots shouldn't be a Problem also ..

everything is working now ....

Thanks again, for your ear :D

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest