半城柳色半声笛

文章 评论 浏览 26

半城柳色半声笛 2024-11-21 19:19:30

好的,我现在已经解决了这个问题。

我应该按如下方式使用#userId...

<input type="hidden" name="userId" id="userId" />

其中 id="userId" 引用#userId。

Ok, I have solved the issue now.

I should have been using #userId as follows...

<input type="hidden" name="userId" id="userId" />

Where id="userId" references the #userId.

将 ID 从 jQuery 自动完成 UI 框获取到 JSP 上的表单中

半城柳色半声笛 2024-11-21 18:16:48

对于原始 html,尝试使用非大写值:

document.getElementById("myHour").value = hour

try with uncapitalized Value, for the raw html:

document.getElementById("myHour").value = hour

HiddenField 的值未更新

半城柳色半声笛 2024-11-21 16:25:46

对这类问题最有效的答案通常是去测试。其他人告诉您不必担心这一点,他们是对的。所有链接的文章都很棒并且值得一读。在大多数实际情况下,您不需要接近 1MB 的局部变量。

但是,如果您想知道天气,您实际上可以拥有 1MB 的局部变量,该怎么办?
正如其他人指出的那样,这是实现细节,结果可能会因平台、编译器版本、供应商等而异。

让我们自己测试一下,看看什么是可能的,什么是不可能的。我在一台带有 VS2010 和 C# 4.0 编译器的 x64 机器上。

这是我的代码:

using System;

namespace SO6301703
{
    struct s64b
    {
        public long f1;
        public long f2;
        public long f3;
        public long f4;
        public long f5;
        public long f6;
        public long f7;
        public long f8;
    }

    struct s256b
    {
        public s64b f1;
        public s64b f2;
        public s64b f3;
        public s64b f4;
    }

    struct s1kb
    {
        public s256b f1;
        public s256b f2;
        public s256b f3;
        public s256b f4;
    }

    struct s8kb
    {
        public s1kb f1;
        public s1kb f2;
        public s1kb f3;
        public s1kb f4;
        public s1kb f5;
        public s1kb f6;
        public s1kb f7;
        public s1kb f8;
    }

    struct s64kb
    {
        public s8kb f1;
        public s8kb f2;
        public s8kb f3;
        public s8kb f4;
        public s8kb f5;
        public s8kb f6;
        public s8kb f7;
        public s8kb f8;

    }

    struct s512kb
    {
        public s64kb f1;
        public s64kb f2;
        public s64kb f3;
        public s64kb f4;
        public s64kb f5;
        public s64kb f6;
        public s64kb f7;
        public s64kb f8;

    }

    struct s1Mb
    {
        public s512kb f1;
        public s512kb f2;

    }

    class Program
    {
        static void Main(string[] args)
        {
            unsafe { Console.WriteLine(sizeof(s1Mb)); }
            s1Mb test;
        }
    }
}

当我编译并运行此代码时,我收到堆栈溢出异常。这意味着至少在某些情况下您确实受到堆栈空间的限制。这确实意味着您拥有的局部变量越多,留给方法调用、递归等的堆栈就越少。

再说一遍:这些考虑几乎不切实际。如果您分配了 1MB 的局部变量,那么您很可能做错了什么。但如果你想知道的话……现在你知道了。

A most fruitful answer to this type of question is usually go and test. Others told you that you should not worry about this and they are kind of right. All the articles that are linked are great and well worth reading. In most practical cases, you won't need anywhere near of 1MB of local variables.

But what if you want to know weather you actually can have 1MB of local variables worth?
As others pointed out this is implementation details, and the results may vary depending on platform, compiler version, vendor, etc.

Let's test this ourselves and see what is possible and what is not. I'm on an x64 machine with VS2010 and C# 4.0 compiler.

Here is my code:

using System;

namespace SO6301703
{
    struct s64b
    {
        public long f1;
        public long f2;
        public long f3;
        public long f4;
        public long f5;
        public long f6;
        public long f7;
        public long f8;
    }

    struct s256b
    {
        public s64b f1;
        public s64b f2;
        public s64b f3;
        public s64b f4;
    }

    struct s1kb
    {
        public s256b f1;
        public s256b f2;
        public s256b f3;
        public s256b f4;
    }

    struct s8kb
    {
        public s1kb f1;
        public s1kb f2;
        public s1kb f3;
        public s1kb f4;
        public s1kb f5;
        public s1kb f6;
        public s1kb f7;
        public s1kb f8;
    }

    struct s64kb
    {
        public s8kb f1;
        public s8kb f2;
        public s8kb f3;
        public s8kb f4;
        public s8kb f5;
        public s8kb f6;
        public s8kb f7;
        public s8kb f8;

    }

    struct s512kb
    {
        public s64kb f1;
        public s64kb f2;
        public s64kb f3;
        public s64kb f4;
        public s64kb f5;
        public s64kb f6;
        public s64kb f7;
        public s64kb f8;

    }

    struct s1Mb
    {
        public s512kb f1;
        public s512kb f2;

    }

    class Program
    {
        static void Main(string[] args)
        {
            unsafe { Console.WriteLine(sizeof(s1Mb)); }
            s1Mb test;
        }
    }
}

When I compile and run this code, I am getting the stack overflow exception. This means that at least in some cases you are indeed limited by the stack space. And it does mean that the more local variables you have, the less stack you have left for method calls, recursion, etc.

Once again: these consideration are hardly ever practical. If you are allocating 1MB worth of local variables, you most likely doing something wrong. But in case you are wondering anyway... now you know.

ValueType 堆栈空间耗尽

半城柳色半声笛 2024-11-21 15:19:27

确保 JPA 注释(例如 @Id 和 @OneToMany)是:

(1) 全部紧邻字段上方。

@Id
public Long id;

(2) 或者,全部紧接在字段的 getter 上方。

private Long id;

@Id
public Long getId(){
    return id;
}

使用组合将导致您看到的错误。

// ERROR

@Id
private Long id;

private List<Child> children;


public Long getId(){
    return id;
}

@OneToMany
public List<Child> getChildren(){
    return id;
}

请注意,一些注释,例如:

@Constraints.Required

@Formats.DateTime(pattern="yyyy-MM-dd")

等...

必须紧接在字段名称上方。你不能把它们放在吸气剂之上。但没关系。

Make sure the JPA annotations (such as @Id and @OneToMany) are either:

(1) All immediately above the fields.

@Id
public Long id;

(2) Or, All immediately above the getter for the fields.

private Long id;

@Id
public Long getId(){
    return id;
}

Using a combination will lead to the error you are seeing.

// ERROR

@Id
private Long id;

private List<Child> children;


public Long getId(){
    return id;
}

@OneToMany
public List<Child> getChildren(){
    return id;
}

Note that some annotations such as:

@Constraints.Required

@Formats.DateTime(pattern="yyyy-MM-dd")

etc...

must be immediately above the field name. You cannot put these above the getters. But that's okay.

Playframework:发生 JPA 错误(无法构建 EntityManagerFactory)

半城柳色半声笛 2024-11-21 13:13:28
  • 声明一个新数组。
  • 迭代旧数组
  • 如果新数组为空,则将当前数组元素添加到其中
  • 如果不是,则迭代新数组
    • 如果新数组中没有任何元素与当前数组元素匹配,则添加它
    • 否则将当前元素的 DURATION 添加到相关新数组的元素
  • Declare a new array.
  • Iterate over the old array
  • If the new array is empty, add the current array element to it
  • If not, iterate over the new array
    • if none of the new array's elements match the current array element, add it
    • else add the current element's DURATION to the relevant new array's element

按3列值对2d数组中的行数据进行分组并求和“h:m”另一列中的格式化值

半城柳色半声笛 2024-11-21 08:59:25

有一种分治算法可以在 O(nlogn) 中找到最接近的点对。尽管这对于您的数据集大小来说可能有点过大了。更多信息此处

There is a divide and conquer algorithm to find the closes pair of points in O(nlogn). Although it may be a but overkill for your data set size. More info on it here

如何从坐标列表中计算到给定点的最近坐标

半城柳色半声笛 2024-11-21 08:03:12

知道了!我改编了这个出色的解决方案 (存档版本):

    <?php
    
    // http://coffeerings.posterous.com/php-simplexml-and-cdata
    // https://web.archive.org/web/20110223233311/http://coffeerings.posterous.com/php-simplexml-and-cdata
    
    // Customized 'SimpleXMLElement' class.
    class SimpleXMLExtended extends SimpleXMLElement {
    
      // Create CDATA section custom function.
      public function addCData( $cdata_text ) {
        $node              = dom_import_simplexml( $this ); 
        $ownerDocumentNode = $node->ownerDocument;
        
        $node->appendChild( $ownerDocumentNode->createCDATASection( $cdata_text )); 
      }
    
    }
    
    // How to create the following example, below:
    // <?xml version="1.0"?>
    // <site>
    //   <title lang="en"><![CDATA[Site Title]]></title>
    // </site>
    
    /*
     * Instead of SimpleXMLElement:
     * $xml = new SimpleXMLElement( '<site/>' );
     * create from custom class, in this case, SimpleXMLExtended.
    */
    
    // Name of the XML file.
    $xmlFile    = 'config.xml';

    // <?xml version="1.0"?>
    // <site></site>
    // ^^^^^^^^^^^^^
    $xml        = new SimpleXMLExtended( '<site/>' );
    
    // Insert '<title><title>' into '<site></site>'.
    // <?xml version="1.0"?>
    // <site>
    //   <title></title>
    //   ^^^^^^^^^^^^^^^
    // </site>
    $xml->title = NULL; // VERY IMPORTANT! We need a node where to append.
    
    // CDATA section custom function.
    // <?xml version="1.0"?>
    // <site></site>
    // <title><![CDATA[Site Title]]></title>
    //        ^^^^^^^^^^^^^^^^^^^^^^
    // </site>
    $xml->title->addCData( 'Site Title' );
    
    // Add an attribute.
    // <?xml version="1.0"?>
    // <site></site>
    //   <title lang="en"><![CDATA[Site Title]]></title>
    //          ^^^^^^^^^^
    // </site>
    $xml->title->addAttribute( 'lang', 'en' );
    
    // Save.
    $xml->saveXML( $xmlFile );
    
    ?>

XML 文件,config.xml,生成:

    <?xml version="1.0"?>
    <site>
      <title lang="en"><![CDATA[Site Title]]></title>
    </site>

谢谢 Petah ,希望有帮助!

Got it! I adapted the code from this great solution (archived version):

    <?php
    
    // http://coffeerings.posterous.com/php-simplexml-and-cdata
    // https://web.archive.org/web/20110223233311/http://coffeerings.posterous.com/php-simplexml-and-cdata
    
    // Customized 'SimpleXMLElement' class.
    class SimpleXMLExtended extends SimpleXMLElement {
    
      // Create CDATA section custom function.
      public function addCData( $cdata_text ) {
        $node              = dom_import_simplexml( $this ); 
        $ownerDocumentNode = $node->ownerDocument;
        
        $node->appendChild( $ownerDocumentNode->createCDATASection( $cdata_text )); 
      }
    
    }
    
    // How to create the following example, below:
    // <?xml version="1.0"?>
    // <site>
    //   <title lang="en"><![CDATA[Site Title]]></title>
    // </site>
    
    /*
     * Instead of SimpleXMLElement:
     * $xml = new SimpleXMLElement( '<site/>' );
     * create from custom class, in this case, SimpleXMLExtended.
    */
    
    // Name of the XML file.
    $xmlFile    = 'config.xml';

    // <?xml version="1.0"?>
    // <site></site>
    // ^^^^^^^^^^^^^
    $xml        = new SimpleXMLExtended( '<site/>' );
    
    // Insert '<title><title>' into '<site></site>'.
    // <?xml version="1.0"?>
    // <site>
    //   <title></title>
    //   ^^^^^^^^^^^^^^^
    // </site>
    $xml->title = NULL; // VERY IMPORTANT! We need a node where to append.
    
    // CDATA section custom function.
    // <?xml version="1.0"?>
    // <site></site>
    // <title><![CDATA[Site Title]]></title>
    //        ^^^^^^^^^^^^^^^^^^^^^^
    // </site>
    $xml->title->addCData( 'Site Title' );
    
    // Add an attribute.
    // <?xml version="1.0"?>
    // <site></site>
    //   <title lang="en"><![CDATA[Site Title]]></title>
    //          ^^^^^^^^^^
    // </site>
    $xml->title->addAttribute( 'lang', 'en' );
    
    // Save.
    $xml->saveXML( $xmlFile );
    
    ?>

XML file, config.xml, generated:

    <?xml version="1.0"?>
    <site>
      <title lang="en"><![CDATA[Site Title]]></title>
    </site>

Thank you Petah, hope it helps!

如何使用SimpleXmlElement编写CDATA?

半城柳色半声笛 2024-11-21 07:11:49

事情远没有那么简单。

当您知道指针如何以及为何与普通变量一起使用时,请考虑使用这些指针,但这次是与函数一起使用。也就是说,您现在用函数的地址替换变量的地址,利用指针的所有功能,您现在可以通过使用指向它们的指针而不是直接使用它们的名称来间接访问函数。

来自 http://www.cplusplus.com/doc/tutorial/pointers/

// my first pointer
#include <iostream>
using namespace std;

int main ()
{
  int firstvalue, secondvalue;
  int * mypointer;

  mypointer = &firstvalue;
  *mypointer = 10;
  mypointer = &secondvalue;
  *mypointer = 20;
  cout << "firstvalue is " << firstvalue << endl;
  cout << "secondvalue is " << secondvalue << endl;
  return 0;
}

并且上述输出现在

firstvalue is 10
secondvalue is 20

来自 http://www.newty.de/fpt/intro .html#what
我们有函数指针。

//------------------------------------------------------------------------------------
// 1.2 Introductory Example or How to Replace a Switch-Statement
// Task: Perform one of the four basic arithmetic operations specified by the
//       characters '+', '-', '*' or '/'.


// The four arithmetic operations ... one of these functions is selected
// at runtime with a swicth or a function pointer
float Plus    (float a, float b) { return a+b; }
float Minus   (float a, float b) { return a-b; }
float Multiply(float a, float b) { return a*b; }
float Divide  (float a, float b) { return a/b; }


// Solution with a switch-statement - <opCode> specifies which operation to execute
void Switch(float a, float b, char opCode)
{
   float result;

   // execute operation
   switch(opCode)
   {
      case '+' : result = Plus     (a, b); break;
      case '-' : result = Minus    (a, b); break;
      case '*' : result = Multiply (a, b); break;
      case '/' : result = Divide   (a, b); break;
   }

   cout << "Switch: 2+5=" << result << endl;         // display result
}


// Solution with a function pointer - <pt2Func> is a function pointer and points to
// a function which takes two floats and returns a float. The function pointer
// "specifies" which operation shall be executed.
void Switch_With_Function_Pointer(float a, float b, float (*pt2Func)(float, float))
{
   float result = pt2Func(a, b);    // call using function pointer

   cout << "Switch replaced by function pointer: 2-5=";  // display result
   cout << result << endl;
}


// Execute example code
void Replace_A_Switch()
{
   cout << endl << "Executing function 'Replace_A_Switch'" << endl;

   Switch(2, 5, /* '+' specifies function 'Plus' to be executed */ '+');
   Switch_With_Function_Pointer(2, 5, /* pointer to function 'Minus' */ &Minus);
}

正如您从上面的调用中看到的,传递了 Minus() 函数的地址,然后传递该地址以通过指针调用实际函数,在本例中为 pt2Func(...)。
请注意,对于函数指针,您还需要处理函数签名。

  • float (*pt2Func)(float, float)
  • float Minus (float a, float b) { return ab; }正如

您在上面看到的,签名是相同的,因此您可以传入任何函数地址并且调用将起作用。

我希望这有帮助。

It is no more simple then this.

When you know how and why pointers work with normal variables, think of using these pointers, but this time with functions. That is, you replace the address of variables now with the address of the function, with all the power of pointers there, you can now access function indirectly by using the pointers that point to them instead of using their names directly.

From http://www.cplusplus.com/doc/tutorial/pointers/

// my first pointer
#include <iostream>
using namespace std;

int main ()
{
  int firstvalue, secondvalue;
  int * mypointer;

  mypointer = &firstvalue;
  *mypointer = 10;
  mypointer = &secondvalue;
  *mypointer = 20;
  cout << "firstvalue is " << firstvalue << endl;
  cout << "secondvalue is " << secondvalue << endl;
  return 0;
}

And the output for the above is

firstvalue is 10
secondvalue is 20

Now from http://www.newty.de/fpt/intro.html#what
We have function pointers.

//------------------------------------------------------------------------------------
// 1.2 Introductory Example or How to Replace a Switch-Statement
// Task: Perform one of the four basic arithmetic operations specified by the
//       characters '+', '-', '*' or '/'.


// The four arithmetic operations ... one of these functions is selected
// at runtime with a swicth or a function pointer
float Plus    (float a, float b) { return a+b; }
float Minus   (float a, float b) { return a-b; }
float Multiply(float a, float b) { return a*b; }
float Divide  (float a, float b) { return a/b; }


// Solution with a switch-statement - <opCode> specifies which operation to execute
void Switch(float a, float b, char opCode)
{
   float result;

   // execute operation
   switch(opCode)
   {
      case '+' : result = Plus     (a, b); break;
      case '-' : result = Minus    (a, b); break;
      case '*' : result = Multiply (a, b); break;
      case '/' : result = Divide   (a, b); break;
   }

   cout << "Switch: 2+5=" << result << endl;         // display result
}


// Solution with a function pointer - <pt2Func> is a function pointer and points to
// a function which takes two floats and returns a float. The function pointer
// "specifies" which operation shall be executed.
void Switch_With_Function_Pointer(float a, float b, float (*pt2Func)(float, float))
{
   float result = pt2Func(a, b);    // call using function pointer

   cout << "Switch replaced by function pointer: 2-5=";  // display result
   cout << result << endl;
}


// Execute example code
void Replace_A_Switch()
{
   cout << endl << "Executing function 'Replace_A_Switch'" << endl;

   Switch(2, 5, /* '+' specifies function 'Plus' to be executed */ '+');
   Switch_With_Function_Pointer(2, 5, /* pointer to function 'Minus' */ &Minus);
}

As you will see from the above call, the address of Minus() function is passed which is then in passed on to call the actual function via pointer and in this case, pt2Func(...).
Note that in the case of function pointers you will take care of the function signature as well.

  • float (*pt2Func)(float, float)
  • float Minus (float a, float b) { return a-b; }

As you can see above, the signatures are the same, so you can pass in any function address and the call will work.

I hope this helps.

C语言中函数指针的解释

半城柳色半声笛 2024-11-21 01:43:34

这是我为此编写的代码的稍微简化的版本。感谢大家的帮助,抱歉我之前忘记发帖了。如果您有任何疑问或任何问题,请随时询问。

Function processString(ByVal scriptString As String)
    ' Functions
    Dim pattern As String = "\[\[((\w+?)\((.*?)\))(?=[^\(+\)]*(\(|$))\]\]"
    scriptString = Regex.Replace(scriptString, pattern, New MatchEvaluator(Function(match) processFunction(match)))

    ' Variables
    pattern = "\[\[([A-Za-z0-9+_]+)\]\]"
    scriptString = Regex.Replace(scriptString, pattern, New MatchEvaluator(Function(match) processVariable(match)))
    Return scriptString
End Function

Function processFunction(ByVal match As Match)
    Dim nameString As String = match.Groups(2).Value
    Dim paramString As String = match.Groups(3).Value
    paramString = processString(paramString)
    Select Case nameString
        Case "time"
            Return getLocalValueTime(paramString)
        Case "math"
            Return getLocalValueMath(paramString)
    End Select
    Return ""
End Function

Function processVariable(ByVal match As Match)
    Try
        Return moduleDictionary("properties")("vars")(match.Groups(1).Value)
    Catch ex As Exception
    End Try
End Function

Here is a slightly simplified version of the code I wrote for this. Thanks for the help everyone and sorry I forgot to post this before. If you have any questions or anything feel free to ask.

Function processString(ByVal scriptString As String)
    ' Functions
    Dim pattern As String = "\[\[((\w+?)\((.*?)\))(?=[^\(+\)]*(\(|$))\]\]"
    scriptString = Regex.Replace(scriptString, pattern, New MatchEvaluator(Function(match) processFunction(match)))

    ' Variables
    pattern = "\[\[([A-Za-z0-9+_]+)\]\]"
    scriptString = Regex.Replace(scriptString, pattern, New MatchEvaluator(Function(match) processVariable(match)))
    Return scriptString
End Function

Function processFunction(ByVal match As Match)
    Dim nameString As String = match.Groups(2).Value
    Dim paramString As String = match.Groups(3).Value
    paramString = processString(paramString)
    Select Case nameString
        Case "time"
            Return getLocalValueTime(paramString)
        Case "math"
            Return getLocalValueMath(paramString)
    End Select
    Return ""
End Function

Function processVariable(ByVal match As Match)
    Try
        Return moduleDictionary("properties")("vars")(match.Groups(1).Value)
    Catch ex As Exception
    End Try
End Function

VB.Net 匹配并替换字符串中多个重叠括号组的内容

半城柳色半声笛 2024-11-21 00:05:38

在 JS 中,将要执行的代码包装在函数中。即

function showInfoBlock() {
    $("#PP_head_bar").slideToggle("slow");
    $("#PP_info_file_wrap").slideUp("slow");
}

在你的PHP中,写出PP_end_show div后调用该函数所需的JS。 IE

<?php echo "<div id=\"PP_end_show\"></div><script>$(function() { showInfoBlock(); })();</script>"; ?>

In your JS, wrap the code you want to execute in a function. i.e.

function showInfoBlock() {
    $("#PP_head_bar").slideToggle("slow");
    $("#PP_info_file_wrap").slideUp("slow");
}

In your PHP, write out the JS needed to call that function after writing out the PP_end_show div. i.e.

<?php echo "<div id=\"PP_end_show\"></div><script>$(function() { showInfoBlock(); })();</script>"; ?>

如何仅在 div 加载时运行函数?

半城柳色半声笛 2024-11-20 23:11:20

只需将 LIMIT 1 添加到 SQL 末尾

Simply add LIMIT 1 to the end of your SQL

如何从 PHP 中的 SQL 查询中获取一个值?

半城柳色半声笛 2024-11-20 22:37:45

当您创建具有父实体的实体时,这些实体将放置在同一实体组中。 App Engine 中的事务只能在单个实体组中工作,因此如果您需要事务,则需要实体组。如果不需要事务,则不需要实体组(特别是,要在不需要事务功能的实体之间建立关系,您应该使用ReferenceProperties,而不是父子关系。)

When you create an entity with a parent, the entities are placed in the same Entity Group. Transactions in App Engine can only work within a single entity group, so if you need transactions, you need entity groups. If you don't need transaction, you don't need entity groups (in particular, to build relationships between entities that don't need transactional capabilities, you should use ReferenceProperties, not parent-child relationships.)

App Engine 数据存储中的祖先

半城柳色半声笛 2024-11-20 21:56:41

是的,您可以根据需要多次加入表。

SELECT 
  sender.ID AS `sender_id`, 
  sender.Name AS `sender_name`, 
  receiver.ID AS `receiver_id`, 
  receiver.Name AS `receiver_name`, 
  Messages.Message
FROM
  Messages
INNER JOIN
  Users AS sender
ON
  sender.ID = Messages.Sender
INNER JOIN
  Users AS receiver
ON
  receiver.ID = Messages.Receiver

Yes, you can join the tables as many times as needed.

SELECT 
  sender.ID AS `sender_id`, 
  sender.Name AS `sender_name`, 
  receiver.ID AS `receiver_id`, 
  receiver.Name AS `receiver_name`, 
  Messages.Message
FROM
  Messages
INNER JOIN
  Users AS sender
ON
  sender.ID = Messages.Sender
INNER JOIN
  Users AS receiver
ON
  receiver.ID = Messages.Receiver

在 MySQL 中连接两个表两次。可能还是不可能???

半城柳色半声笛 2024-11-20 12:15:39

尝试使用类似 nohup 的工具在远程服务器上启动节点进程。

bash$ nohup /path/to/node server.js > out.txt 2> err.txt &
[1] 53032
# Now you can logout of the remote server without
#   killing the "node" process and chat server.

[编辑]

请注意,“nohup”打印的数字(例如 53032)是分离进程的 ID,因此如果您需要终止它,可以执行类似“kill -9 53032”的操作”。如果您忘记记录该号码,则必须使用“ps”等程序来查找它;例如,您可以运行“ps auxwww | grep node”(标志将根据您的系统而有所不同),您将看到与此类似的输出:

maerics  81694   0.6  0.5  2543604  21216 s000  S+   10:34AM   0:09.45 /Users/maerics/opt/node/node server.js

在此示例中,在我的系统上,数字第二列是进程 ID。

Try launching your node process on the remote server using a tool like nohup.

bash$ nohup /path/to/node server.js > out.txt 2> err.txt &
[1] 53032
# Now you can logout of the remote server without
#   killing the "node" process and chat server.

[Edit]

Note that the number printed by "nohup" (e.g. 53032) is the id of detached process, so if you need to terminate it you can do something like "kill -9 53032". If you forgot to record that number then you'll have to find it by using a program such as "ps"; for example, you can run "ps auxwww | grep node" (the flags will vary depending on your system) and you'll see output similar to this:

maerics  81694   0.6  0.5  2543604  21216 s000  S+   10:34AM   0:09.45 /Users/maerics/opt/node/node server.js

In this example, on my system, the number in the second column is the process id.

Nodejs 服务器 - Mac 终端每隔一小时崩溃一次

半城柳色半声笛 2024-11-20 11:27:01

就在今天,我遇到了类似的情况(但在其他情况下,我试图从数据库创建实体)。

我解决了这个问题,只需将parameters.ini文件中的database_host“localhost”修改为“127.0.0.1”

我认为我的 Mysql 实例仅通过 TCP 而不是套接字运行,因为当使用 database_host="localhost" 时它会失败。

Just today I had a similar situation (but in other context, I was trying to create entities from db).

I solved it simply modifying the database_host from "localhost" to "127.0.0.1" in the parameters.ini file.

I think my Mysql instance is running only via TCP and not socket and because this when use database_host="localhost" it fails.

解决“没有这样的文件或目录”的问题运行 `php app/console 学说:schema:create` 时

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文