I have a problem in app rails.
My app works fine on the development server, but on my host it does not work when uploading, and throws me this error on any path of my application.
I checked all the drivers to see if there are any closures, but I did not find anything unusual.
Here I show my log production.
I, [2017-07-06T02:47:57.031902 #30638] INFO -- : Started GET "/" for 187.204.162.35 at 2017-07-06 02:47:57 +0200
I, [2017-07-06T02:47:57.046063 #30638] INFO -- : Processing by WelcomeController#index as HTML
I, [2017-07-06T02:47:57.608254 #30638] INFO -- : Rendered welcome/index.html.erb within layouts/application (535.1ms)
I, [2017-07-06T02:47:57.608542 #30638] INFO -- : Completed 500 Internal Server Error in 562ms (ActiveRecord: 0.0ms)
F, [2017-07-06T02:47:57.610259 #30638] FATAL -- :
ActionView::Template::Error (SyntaxError: Unexpected token: keyword (else)):
130: <div class="row">
131:
132: <div class="col-md-4">
133: <%= image_tag("mision.png", :style => "width: 50px; margin: auto; display: block;", class: "img-responsive") %>
134: <h3 class="text-center" style="color: #004467;"><strong>MISIÓN</strong></h3>
135: <p style=" text-align: justify;">Hacer realidad los sueños de nuestros clientes Lo logramos con: propuestas y soluciones claras, asesoría persona$
136: </div>
app/views/welcome/index.html.erb:133:in `_app_views_welcome_index_html_erb___3018899638396619987_70193610437540'
Related
I am following this Google CoLab tutorial and error on Step 5, custom model training job using a scikit-learn prebuilt container.
The training code works locally with the same environment as the container. But when I submit a training job, I get the following error:
The replica workerpool0-0 exited with a non-zero status of 1.
Traceback (most recent call last):
[...]
google.api_core.exceptions.NotFound: 404 POST https://bigquery.googleapis.com/bigquery/v2/projects//my-project/jobs?prettyPrint=false: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/bigquery/v2/projects//my-project/jobs?prettyPrint=false</code> was not found on this server. <ins>That’s all we know.</ins>
(job ID: my-job-id)
-----Query Job SQL Follows-----
| . | . | . |
1:
2: SELECT * from titanic.survivors"
3:
| . | . | . |
It seems like a problem with google-api-core but I am confused as to why this fails in the cloud when it runs locally with the same dependencies.
The error https://bigquery.googleapis.com/bigquery/v2/projects//my-project/jobs?prettyPrint=false also does not look right because of the projects//my-project but the training job submits that request.
Kestrel in ASP.NET 5 Core MVC application in Debian writes escape codes to /var/log/syslog text file like
Apr 5 22:02:21 ew kestrel-store[31907]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Apr 5 22:02:21 ew kestrel-store[31907]: Now listening on: http://localhost:5000
Apr 5 22:02:21 ew kestrel-store[31907]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Apr 5 22:02:21 ew kestrel-store[31907]: Application started. Press Ctrl+C to shut down.
Apr 5 22:02:21 ew kestrel-store[31907]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Apr 5 22:02:21 ew kestrel-store[31907]: Hosting environment: Production
Apr 5 22:02:21 ew kestrel-store[31907]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: Microsoft.Hosting.Lifetime[0]
Apr 5 22:02:21 ew kestrel-store[31907]: Content root path: /var/www/store5
This file is read by MVC controller and sent to user in view.
How to convert this file to html (for example, using colored or italic lines) or remove escape codes from file so that file is easier to read ?
Or how to force kestrel output plain text without escape codes ?
Controller code:
public IActionResult Syslog()
{
return new ContentResult()
{
Content = FileToStr("/var/log/syslog")
};
}
static string FileToStr(string cFileName)
{
StreamReader oReader = File.OpenText(cFileName);
string lcString = oReader.ReadToEnd();
oReader.Close();
return lcString;
}
Escape sequence is defined as:
One \x1b
One [
Zero or more parameter bytes 0x30-0x3f
Zero or more intermediate bytes 0x20-0x2f
One final byte 0x40-0x7f
Update
Code in answer adds span to start of every line and does not remove escape sequences:
<span style="color: blue">Apr 8 00:00:05 ew rsyslogd: [origin software="rsyslogd" swVersion="8.1901.0" x-pid="573" x-info="https://www.rsyslog.com"] rsyslogd was HUPed</span>
<span style="color: blue">Apr 8 00:00:05 ew systemd[1]: logrotate.service: Succeeded.</span>
<span style="color: blue">Apr 8 00:00:05 ew systemd[1]: Started Rotate log files.</span>
<span style="color: blue">Apr 8 00:00:10 ew colord[1172]: failed to get session [pid 23699]: No data available</span>
<span style="color: blue">Apr 8 00:00:12 ew colord[1172]: failed to get session [pid 23699]: No data available</span>
<span style="color: blue">Apr 8 00:00:14 ew colord[1172]: failed to get session [pid 23699]: No data available</span>
<span style="color: blue">Apr 8 00:05:01 ew CRON[23838]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)</span>
<span style="color: blue">Apr 8 00:15:01 ew CRON[24082]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)</span>
<span style="color: blue">Apr 8 00:17:01 ew CRON[24128]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)</span>
<span style="color: blue">Apr 8 00:21:49 ew kestrel-store[22413]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware[1000]</span>
<span style="color: blue">Apr 8 00:21:49 ew kestrel-store[22413]: Request started for '/c/version.js'</span>
<span style="color: blue">Apr 8 00:21:49 ew kestrel-store[22413]: #033[41m#033[30mfail#033[39m#033[22m#033[49m: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]</span>
<span style="color: blue">Apr 8 00:21:49 ew kestrel-store[22413]: An unhandled exception has occurred while executing the request.</span>
Expected output is:
Hope this is helpful. I used rextester.com write a formatted code. But tests with files doesn't work there.
Please correct this post if necessary. Also its not the shortest version, but I think its most clear.
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
using (var reader = new StreamReader(#"c:\your_input_file.txt"))
using (var writer = new StreamWriter(#"c:\your_output_file.html"))
{
WriteHtmlHeader(writer);
string line;
while((line = reader.ReadLine()) != null)
{
line = AddSpan(line);
}
WriteHtmlFooter(writer);
}
}
private static void WriteHtmlHeader(StreamWriter outfile)
{
// writing all the header and the start of body...
// you can take it from another file
}
private static void WriteHtmlFooter(StreamWriter outfile)
{
// writing the footer of your html file
}
private static string AddSpan(string line)
{
if (Regex.IsMatch(line, "\x1b"))
{
return AddStyledSpan(line, "color: green");
}
else if (Regex.IsMatch(line, "\["))
{
return AddStyledSpan(line, "color: blue");
}
// ...
else
{
// Mark this span as error or standard
return AddStyledSpan(line, "color: red");
}
}
private static string AddStyledSpan(string line, string style)
{
return "<span style=\"" + style + "\">" + line + "</span>";
}
}
}
Hope this helps. Also look at
regex101 - online regex tester
and
debuggex - regex visualization.
(But use it carefully, regular expressions works somtimes different).
I am trying to run cloud_sql_proxy installed as a binary from go get, but I always get a 404 Error.
I have followed the instructions at https://github.com/GoogleCloudPlatform/cloudsql-proxy, but with no luck.
$GOPATH/go/bin/cloud_sql_proxy -instances=project_name:region:instance_name=tcp:3306 -credential_file=/path/to/cloud-sql-proxy.json
The error I get:
2020/01/18 13:20:03 Rlimits for file descriptors set to {&{8500 9223372036854775807}}
2020/01/18 13:20:03 using credential file for authentication; email=<EMAIL>
2020/01/18 13:20:03 errors parsing config:
googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/sql/v1beta4/sql/v1beta4/projects/project_name/instances/instance_name?alt=json&prettyPrint=false</code> was not found on this server. <ins>That’s all we know.</ins>
However, if I get the binary from https://cloud.google.com/sql/docs/mysql/sql-proxy, then the connection if fine, proving that the instance address and the credential file work just fine. The service account has also the Cloud SQL Admin role, so that should be just fine as well.
I have cloned the repo, and tried to debug the code to see where exactly if fails, and of course, it fails at:
cmd/cloud_sql_proxy/proxy.go:268
sql.BasePath = *host
inst, err := sql.Instances.Get(proj, name).Do()
if err != nil {
return instanceConfig{}, err
}
The reason I am insisting on using the go-binary is that I want to re-use cloud_sql_proxy on Raspberry PI 3b+, and this seems to be the only option of getting cloud_sql_proxy working on ARM architecture.
I have the following playbook that is trying to assert that a user prompt variable of NX-OS image equals the ansible_net_image captured from a Nexus switch. This is driving me crazy as to the correct format for the test condition.
---
- name: Upgrade NX-OS on switch with pre-checks to load image as required
hosts: nexus-7000
gather_facts: no
vars_prompt:
- name: NX_OS_Upgrade_Version
prompt: "Please enter NX-OS version to upgrade too - ensure that the filename is as used by boot variable"
private: no
##############################################################################
## Start of task execution
##############################################################################
tasks:
- name: Gather IOS configuration and software facts from switches
nxos_facts:
gather_subset: "!hardware"
################################################################################
## Display running image version to terminal
################################################################################
- debug:
msg: "{{ NX_OS_Upgrade_Version }}"
- assert:
that:
- "ansible_net_image | regex:/^bootflash:\\/\\/\\/(.*) == NX_OS_Upgrade_Version"
Upon execution this error is displayed.
fatal: [switcha]: FAILED! => {"msg": "The conditional check 'ansible_net_image | regex:/^bootflash:\/\/\/(.) == NX_OS_Upgrade_Version' failed. The error was: template error while templating string: expected token 'end of statement block', got '/'. String: {% if ansible_net_image | regex:/^bootflash:\/\/\/(.) == NX_OS_Upgrade_Version %} True {% else %} False {% endif %}"}
fatal: [switchb]: FAILED! => {"msg": "The conditional check 'ansible_net_image | regex:/^bootflash:\/\/\/(.) == NX_OS_Upgrade_Version' failed. The error was: template error while templating string: expected token 'end of statement block', got '/'. String: {% if ansible_net_image | regex:/^bootflash:\/\/\/(.) == NX_OS_Upgrade_Version %} True {% else %} False {% endif %}"}
The regex has been tested, but I am struggling to get the correct syntax for the Ansible play.
It would be great if someone could show me what I have got wrong.
Use 7.3.2. Single-Quoted Style to create regex.
See Testing strings.
For example
- hosts: localhost
vars:
ansible_net_image: 'bootflash:///n5000-uk9-kickstart.5.1.3.N2.1b.bin'
NX_OS_Upgrade_Version1: 'n5000-uk9-kickstart.5.1.3.N2.1b'
my_regex1: '^bootflash:///{{ NX_OS_Upgrade_Version1 }}.bin'
NX_OS_Upgrade_Version2: 'n5000-uk9-kickstart.5.1.4.N2.1b'
my_regex2: '^bootflash:///{{ NX_OS_Upgrade_Version2 }}.bin'
tasks:
- assert:
that: ansible_net_image is match(my_regex1)
success_msg: "Image is version {{ NX_OS_Upgrade_Version1 }}"
fail_msg: "Image is NOT version {{ NX_OS_Upgrade_Version1 }}"
- assert:
that: ansible_net_image is match(my_regex2)
success_msg: "Image is version {{ NX_OS_Upgrade_Version2 }}"
fail_msg: "Image is NOT version {{ NX_OS_Upgrade_Version2 }}"
gives
ok: [localhost] => {
"changed": false,
"msg": "Image is version n5000-uk9-kickstart.5.1.3.N2.1b"
}
fatal: [localhost]: FAILED! => {
"assertion": "ansible_net_image is match(my_regex2)",
"changed": false,
"evaluated_to": false,
"msg": "Image is NOT version n5000-uk9-kickstart.5.1.4.N2.1b"
}
I had setup a simple Django project in hostmonster:
The project name is thep_viet, the app is mainapp
my .htaccess is
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
my django.fcgi is
#!/usr/bin/env python
# -*- mode: python; -*-
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home/riasolut/django/django_projects/")
# Switch to the directory of your project. (Optional.)
#os.chdir("/home/riasolut/django/django_projects/thep_viet")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "thep_viet.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
I'm setting python 2.7.2 and django 1.3.1 succesfully
I'm create a folder named thep_viet in ~/django/django_projects/. This folder contain all source code of thep_viet project.
I'm create a folder named thep_viet in public_html and place .htaccess and django.fcgi in this.
When I'm running django.fcgi by command line:
python ~/public_html/thep_viet/django.fcgi
I receive the result:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to Django</title>
<style type="text/css">
html * { padding:0; margin:0; }
body * { padding:10px 20px; }
body * * { padding:0; }
body { font:small sans-serif; }
body>div { border-bottom:1px solid #ddd; }
h1 { font-weight:normal; }
h2 { margin-bottom:.8em; }
h2 span { font-size:80%; color:#666; font-weight:normal; }
h3 { margin:1em 0 .5em 0; }
h4 { margin:0 0 .5em 0; font-weight: normal; }
table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }
tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
ul { margin-left: 2em; margin-top: 1em; }
#summary { background: #e0ebff; }
#summary h2 { font-weight: normal; color: #666; }
#explanation { background:#eee; }
#instructions { background:#f6f6f6; }
#summary table { border:none; background:transparent; }
</style>
</head>
<body>
<div id="summary">
<h1>It worked!</h1>
<h2>Congratulations on your first Django-powered page.</h2>
</div>
<div id="instructions">
<p>Of course, you haven't actually done any work yet. Here's what to do next:</p>
<ul>
<li>If you plan to use a database, edit the <code>DATABASES</code> setting in <code>thep_viet/settings.py</code>.</li>
<li>Start your first app by running <code>python thep_viet/manage.py startapp [appname]</code>.</li>
</ul>
</div>
<div id="explanation">
<p>
You're seeing this message because you have <code>DEBUG = True</code> in your
Django settings file and you haven't configured any URLs. Get to work!
</p>
</div>
</body></html>
It seem django can run effectly
But when I'm running in browser:
thepviet.mydomain.com
with thepviet.mydomain.com point to mydomain.com/thep_viet
I receive the 500 error:
<!-- SHTML Wrapper - 500 Server Error -->
[an error occurred while processing this directive]
Did I forget any thing? I thing something wrong in config fastcgi in apache of hostmonster.
Please help my problem.
I've read the error log and found:
[Fri Nov 18 19:50:04 2011] [warn] [client 113.185.2.152] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Nov 18 19:50:04 2011] [error] [client 113.185.2.152] Premature end of script headers: django.fcgi
[Fri Nov 18 19:50:04 2011] [error] [client 113.185.2.152] invalid CGI ref "/500.php" in /home4/riasolut/public_html/500.shtml
Is this error belong to the FastCGI server or my code?
You have a syntax error in your fcgi file:
runfastcgi(method="threaded", "daemonize="false")
The quote mark before daemonize shouldn't be there.
As Jack M says in the comment, if you'd looked in the server error log, you would almost certainly see the error there.