w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
HAProxy, Nginx & Node.js SPDY termination
Nginx can handle non-encrypted SPDY frame. Simply use "listen" directive without "ssl" part: listen 8000 spdy; "HAproxy (SSL termination) -> Nginx (SPDY) -> your network (HTTP)" setup is described at https://kura.io/2013/07/15/haproxy-nginx-and-spdy-with-ssl-termination-debian-7/

Categories : Node Js

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass; } In apache you create a virtual host <Virtua

Categories : Apache

Asp.net session termination
Do you wan't to log out the user? In that case killing of the session won't work for you. If you use Forms Authentication, you can execute FormsAuthentication.SignOut method to do that.

Categories : C#

Program termination callback in QT?
You need to handle Linux-style signals. Note - this will not work on Windows or Mac if you are trying to be cross platform. See the Qt article Calling Qt Functions From Unix Signal Handlers. Here is a minimal setup example extracted from the article: class MyDaemon : public QObject { ... public: static void hupSignalHandler(int unused); public slots: void handleSigHup(); private: static int sighupFd[2]; QSocketNotifier *snHup; }; MyDaemon::MyDaemon(...) { if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighupFd)) qFatal("Couldn't create HUP socketpair"); snHup = new QSocketNotifier(sighupFd[1], QSocketNotifier::Read, this); connect(snHup, SIGNAL(activated(int)), this, SLOT(handleSigHup())); } static int setup_unix_signal_handlers() { struct siga

Categories : C++

Null termination of C string
First question: yes Second question: yes on a ASCII system: you calculate '4' - '2' + '' which is in integers: 0x34 - 0x32 + 0 = 2 so you get str[2] which is '2' which is 0x32. '4' - '2' to be 2 is defined in C, but if you ran your code on an EBCDIC system, '2' was 0xf2

Categories : C

Correct greenlet termination
Why not try something like: timeout = Timeout(10) def downloadSite(url): with Timeout(10): downloadUrl(url) urls = ["url1", "url2", "url3"] workers = [] limit = 5 counter = 0 for i in urls: # limit to 5 URL requests at a time if counter < limit: workers.append(gevent.spawn(downloadSite, i)) counter += 1 else: gevent.joinall(workers) workers = [i,] counter = 0 gevent.joinall(workers) You could also save a status in a dict or something for every URL, or append the ones that fail in a different array, to retry later.

Categories : Python

Get Process Information After Termination
Quoting from man 5 proc: /proc/[pid] There is a numerical subdirectory for each running process; the subdirectory is named by the process ID. A terminated process is no longer running, and its /proc/[pid] directory (including the stat file), is no longer going to be there. If it was going to be there, you can just store the PID in a variable before you call proc.wait(): pid = proc.pid proc.wait() with open('/proc/%d/stat' % pid, "r") as f: There is no 'just before termination' event; subprocess waits, then reaps the exit code. You could do your own waiting with os.wait4() instead: pid, status, resources = os.wait4(proc.pid, 0) cpu_time = resources.ru_utime + resources.ru_stime resources is a named tuple, see resource.getrusage() for a list of what names it supports. Both .

Categories : Python

While loop termination in Python
the counter i gets increased by another function Impossible. it is a local integer. The values printed are values of a different variable. Try add print i inside the loop, and you'll see. int is an immutable type. it means an object of this type cannot change its value. The only thing can change is the object that some variable is holding. def inc(i): i+=1 i=0 inc(i) print i output: 0 why is this? because i inside inc and i outside it are two independent variable. The i+=1 inside inc only mean "Let the local variable i now point to a new object, 2". It does not affect the global i in any way. Just like C and Java (and the default in most other major languages), variables are passed by value. The only way this loop can end is if function removes elements from f, assuming

Categories : Python

termination of finite lists
One way to prove that a recursive calculation will terminate if the size of its input is (a) finite and (b) decreasing. Let's look at pp pp :: [a] -> [a] pp list = case list of [] -> [] (x: _) -> x : (qq list) The last line returns x:qq list, but the input was list, so it calls qq with the same length list. Let's see what qq does: qq :: [a] -> [a] qq list = case list of [] -> [] (x: xs) -> (pp xs) ++ [x] Here, we call pp xs, where we've matched list with the pattern x:xs. This means x is the head (first element) and xs is the tail (rest-of-list), so xs is one element shorter than the input, list. This means that the length of the input decreases by one every time we call qq and doesn't decrease when we call pp. Hence you're right that there are a

Categories : Haskell

Unusual termination in try catch throw
There's a compelling example in the C++ Standard, [except.throw]/1: Example: throw "Help!"; can be caught by a handler of const char* type: try { // ... } catch(const char* p) { // handle character string exceptions here } When you throw via throw "Error: Cannot divide by zero ";, the expression after throw is a string literal, therefore of type array of n const char (where n is the length of the string + 1). This array type is decayed to a pointer [except.throw]/3, therefore the type of the object thrown is char const*. Which types are catched by a handler (catch) is described in [except.handle]/3, and none of the cases apply here, i.e. the const char* is not catched by a handler of type char*.

Categories : C++

Checking for abnormal socket termination
(decided to move this to an answer) BufferedReader.readLine() returns null if the socket is closed as per the docs. Your if statement's first condition as shown: if (null != lastLine && !lastLine.equals ("QUIT")) will evaluate to false if that is the case (or, your computer is broken ;) ). If your logging says "null" and it's not evaluating to false ... then the string contains the actual text "null". Put it in the debugger, set a breakpoint in this loop, and step through looking at the value of lastLine; you will see what's going on. That said, the first rule of writing a server is never trust the client. Like in the case of your using telnet ultimately you don't have any control over what's being sent to you. When you read from that socket, you need to be doing more input

Categories : Java

C++ varadic template class termination
Your most general case takes at least 1 argument (pin), so you cannot create a specialization, that has 0 arguments. Instead, you should make most general case, that accepts any amount of arguments: template< typename... > class tee; And then create specializations: template< typename pin, typename... tail_args > class tee<pin, tail_args...> { public: typedef tee< tail_args... > tail; static void set( bool b ){ pin::set( b ); tail::set( b ); } }; template<> class tee<> { public: static void set( bool b ){} };

Categories : C++

What is "Terminating in response to backboardd's termination"?
backboardd is the companion daemon for SpringBoard. "Terminating in response to backboardd's termination” most likely means that backboardd crashed. Check to see if there are any backboardd crash logs and, if present, file a bug report with Apple.

Categories : IOS

Unexpected termination of my Java program
Your for loop is wrong. It will only ever loop once and only if testCases is 1. Try this instead: for( int loop1 = 0; loop1 < testCases; ++loop1 ) FYI - There is nothing wrong with starting at 1 and going until <= numIterations, however general programming convention is to start at value 0 and go till < numIterations because that is how arrays work (1st element is at index 0, then 10th is at index 9).

Categories : Java

Termination of PHP script between two mysql queries
Use a transaction: START TRANSACTION; INSERT INTO foo ... INSERT INTO bar ... COMMIT If either INSERT fails, you ROLLBACK the transaction and you won't be left with "useless" records.

Categories : PHP

Local notification on application termination
You will not receive any notice when it gets terminated, when your app is suspended in the background. iOS will send a kill -9 signal for your apps progress and you app is just killed, this is the same thing that happens when the user kills your app from the quicklaunch tray. From the Apple documentation: Even if you develop your app using iOS SDK 4 and later, you must still be prepared for your app to be killed without any notification. The user can kill apps explicitly using the multitasking UI. In addition, if memory becomes constrained, the system might remove apps from memory to make more room. Suspended apps are not notified of termination but if your app is currently running in the background state (and not suspended), the system calls the applicationWillTerminat

Categories : Iphone

Java - Polar Coordinates. Given a line segment AB and a point P, find the closest point on the polar line AB to point P
public static Location closest(double x1, double y1, double x2, double y2, double x3, double y3){ Location a = new Location("provider"); Location b = new Location("provider"); Location c = new Location("provider"); //I can't remember which one goes where, you may need to swap all the x/ys around //Do conversion or something here. a.setLongitude(x1); a.setLatitude(y1); b.setLongitude(x2); b.setLatitude(y2); c.setLongitude(x3); c.setLongitude(y3); return closest(a, b, c); } public static Location closest(Location a, Location b, Location c){ return a.distanceTo(c) < b.distanceTo(c) ? a : b; }

Categories : Java

shell script process termination issue
SIGKILL cannot be trapped by the trap command, or by any process. It is a guarenteed kill signal, that by it's definition cannot be trapped. Thus upgrading you sh/bash will not work anyway.

Categories : Shell

capturing Command Line termination during installation
yes, using trap is the way to go control_c() # run if user hits control-c { echo -en " *** Ouch! Exiting *** " cleanup exit $? } # trap keyboard interrupt (control-c) trap control_c SIGINT and to trap the signal sent with Control-Z key, you need to trap the SIGTSTP signal: control_z() { echo -e " *** Suspending asked... Exiting! ***" cleanup exit $? } trap control_z SIGTSTP

Categories : Linux

GLib program termination signal handling?
here is, what I found: GLib documentation So basically I guess that signal() is the GLib way of doing this.

Categories : C

Premature termination of "Random Walk" program
You have for(i = 0; i < 26; i++) with no internal loop. This means you will have 26 tries and not 26 moves. You need an internal loop, that will try to go in a random direction and will only exit if all 4 directions were checked. Note: Counting the number of tries (move_count) is not going to work, as rand can give you the same direction multiple times.

Categories : C

How to notify an abnormal client termination to server?
Edit: that answer misses the question, because it's not about using kqueue. But if someone else finds the question by the title, it may be helpful anyway ... I've often seen the following behaviour: if a client dies, and the server does a select() on the client's socket descriptor, select() returns with return code > 0 and FD_ISSET( fd ) will be true for that descriptor. But when you now try to read form the socket, read() (or recv()) return ERROR. For a 'normal' connection using that to detect a client's death works fine for us, but there seems to be a different behaviour when the socket connection is tunneled but we haven't yet managed to figure that out completely.

Categories : C

Checking for termination when converting real to rational
This can be considered a 2D minimization problem on error: ArgMin ( r - q / p ), where r is real, q and p are integers I suggest the use of Gradient Descent algorithm . The gradient in this objective function is: f'(q, p) = (-1/p, q/p^2) The initial guess r_o can be q being the closest integer to r, and p being 1. The stopping condition can be thresholding of the error. The pseudo-code of GD can be found in wiki: http://en.wikipedia.org/wiki/Gradient_descent If the initial guess is close enough, the objective function should be convex. As Jacob suggested, this problem can be better solved by minimizing the following error function: ArgMin ( p * r - q ), where r is real, q and p are integers This is linear programming, which can be efficiently solved by any ILP (Integer L

Categories : Algorithm

How long does thread creation and termination take under Windows?
I wrote this quite a while ago when I had the same basic question (along with another that will be obvious). I've updated it to show a little more about not only how long it takes to create threads, but how long it takes for the threads to start executing: #include <windows.h> #include <iostream> #include <time.h> #include <vector> const int num_threads = 32; const int switches_per_thread = 100000; DWORD __stdcall ThreadProc(void *start) { QueryPerformanceCounter((LARGE_INTEGER *) start); for (int i=0;i<switches_per_thread; i++) Sleep(0); return 0; } int main(void) { HANDLE threads[num_threads]; DWORD junk; std::vector<LARGE_INTEGER> start_times(num_threads); LARGE_INTEGER l; QueryPerformanceCounter(&l);

Categories : C++

Why does a java program closes on termination but not a web browser
A program started via main() can keep running, despite reaching the end of the main method. That can happen if you create new threads, which incidentally happens with GUI programs. AWT (and swing by extension) have an event loop handling the event queue. Other toolkits handle it more or less similarly. They usually have a method/function that enters the loop. At least some also allow taking control of the toolkit's event loop, if the application needs more complete control. Then the loop can be explicit in the application code. So, where exactly the loop is, depends on the browser implementation.

Categories : Java

MFC application hangs in thread signaled for termination
You get a deadlock when the worker thread attempts to access controls that were created in the main thread and the main thread is suspended in WaitForSingleObject. Updating controls from the worker thread can only proceed when the main thread accepts the associated message to the control. Remove all accesses to the controls from the worker thread. Instead, PostMessage a custom message to a window in the main thread. An example is here: http://vcfaq.mvps.org/mfc/12.htm The same technique could be used to notify the main thread that the worker thread has completed, so you could avoid WaitForSingleObject.

Categories : C++

Lazy foldRight early termination confusion
In f(h,t.foldRight(z)(f)), the first argument provided to f is h, the second argument is t.foldRight(z)(f). The way foldRight is defined is that the second argument of its f argument is a by-name argument which will not be evaluated until needed (and will be evaluated everytime it is needed). So in f: (A, =>B) => B, the first argument of type A is a normal argument, but the second one of type B is a by-name argument. So pretend you defined f like this: f(a: A, b: => Boolean): Boolean = predicate(a) || b If predicate(a) is true then b is never needed and will never be evaluated. That is the way the or operator works. So say for exists applied to some Stream. For the first element to be unconsed that will exist (where p(h) is true) this code: uncons match { case Some((h,t))

Categories : Scala

amazon spot instance termination issue
In short answer if another user is bidding more for the instances and there are no more spare available instances then the spot price increases and the first group of instances that fall below that price are SHUTDOWN instantly. Quoting http://aws.amazon.com/ec2/spot-instances/ Spot Instances allow you to name your own price for Amazon EC2 computing capacity. You simply bid on spare Amazon EC2 instances and run them whenever your bid exceeds the current Spot Price, which varies in real-time based on supply and demand.

Categories : Amazon

How to prevent a service from getting killed, because process termination?
Android seems to be killing my process on older model phones Android terminates processes to free up memory to run other apps. Android will also terminate processes at user request via task managers. Are there any plausible solutions to prevent this service from being killed, when the process gets terminated? No. Moreover, you do not need it running forever. Put your receiver in the manifest to watch for incoming messages, convert your service to an IntentService, and have the receiver call startService() to send the messages to the service for processing.

Categories : Android

How can I prevent EC2 instance termination by Auto Scaling?
This functionality is currently not available for Auto Scaling of Amazon EC2 instances - while you are indeed able to Configure [an] Instance Termination Policy for Your Auto Scaling Group, the available policies do not include such a (fairly advanced) concept: Auto Scaling provides the following termination policy options for you to choose from. You can specify one or more of these options in your termination policy. OldestInstance — Specify this if you want the oldest instance in your Auto Scaling group to be terminated. [...] NewestInstance — Specify this if you want the last launched instance to be terminated. [...] OldestLaunchConfiguration — Specify this if you want the instance launched using the oldest launch configuration to be terminated. [...] Close

Categories : Amazon

Golang: Chdir and stay there on program termination
The working directory of every process is process-private. You'll have to jump loops to achieve this. For example, your program can write a script (file), which can be executed later, after you program terminates, from a script, which invoked your program. Another, less hacky method is: $ cd $(prog) where prog writes the new wd to stdout.

Categories : Go

Termination of python script while using ZeroMQ with dead server
You are encountering ZeroMQ's LINGER behaviour. LINGER defines how long the Context should wait before allowing Context.term to discard messages. The default in ZeroMQ 2.x is forever, and the default in ZeroMQ 3.x is one second. If you tell your sockets that they should only linger a short time, your script should exit just fine: socket = context.socket(zmq.REQ) socket_id = randomID() socket.identity = ramdomID() socket.linger = 250 # 250ms = 1/4 s socket.connect("tcp://dead_server")

Categories : Python

How to use the pointer given from MapViewOfFile when its not ending with a Null termination character?
I guess strstr is not the right function for this purpose... You could use memchr to locate the first character and afterwards check, if the rest fits: int chr = 'a'; //DWORD size = GetFileSize(OpenH); unsigned length = ... // obtain length of pBuf const void* ptr = memchr(pBuf, chr, length); if(ptr != NULL){ .... } This is a little bit tedious, but will lead to a result eventually. EDIT: Using the Win32 GetFileSize-function you can determine the current size of the file, should work with mapping, too.

Categories : C

Heroku-forward error on proxy server termination
That issue is probably not happening in the startup of the new dyno: its more likely in the shutdown of the old dyno. Seen similar issues when the Rack configuration file doesn't actually run the app (config.ru should end with a to_app call). Are you using a custom config.ru file?

Categories : Ruby On Rails

Python ctrl+c, excute function if early termination
Either catch and handle KeyboardInterrupt, or set an exit handler with atexit. Also, tempfile.

Categories : Python

How to call the destroy-method for each bean in the container just before termination
All the destroy methods are called when the context is closed or refreshed. If you run a standalone application, in order to make sure that destroy methods are called before the application ends, you need to register a shutdown hook. All these methods are available in the ConfigurableApplicationContext interface, so you need to use that instead of the mere ApplicationContext (pretty much any context you're going to use will implement this interface so you don't need to worry): ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("Beans.xml"); ctx.registerShutdownHook(); // this should be it, destroys are called before your app exits In non stand-alone (managed) scenarios like application servers, closing / refreshing the context happens automatically at shutdown / re

Categories : Java

How to mark NULL data in Point Cloud Library (PCL) when using Iterative Closest Point (ICP)
If you are using PCL, default value of invalid data is not NULL, but is NaN. So if you want to mark a point as invalid, you should first include <limits> file and then set the positions to 'std::numeric_limits::quiet_NaN()'. It is usually done like this const float bad_point = std::numeric_limits<float>::quiet_NaN(); if( is_invalid_point ) p.x = p.y = p.z = bad_point; But anyway, configuring ICP can be a pain. You may have to do a lot more parameter tweaking depending on your data.

Categories : C++

How can I vary the colour of a point on a scatter-graph in VBA/Excel as a function of the X, Y co-ordinates of the point itself?
Here's a simple example of how to access the x and y value for each point: Sub Tester() Dim s As Series, i As Long, x, y Set s = ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1) For i = 1 To s.Points.Count x = s.XValues(i) y = s.Values(i) If x > 3 And y < 40 Then s.Points(i).MarkerBackgroundColor = vbRed End If Next i End Sub

Categories : Vba

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.