w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Disable logging in a node.js script running with forever
There's a nifty tool that can help you that called logrotate. Have a look here Especially the copytruncate option, it is very useful in your case.

Categories : Node Js

Running two node servers from a single shell command using a shell script
Your command does not work because you are trying to have two processes running in the same shell. Instead, you should 'spawn' the node processes into different processes. Try this command: node project/rest.js & node static-server.js &

Categories : Node Js

Node.js node-apn module for Apple Push Notification stopped working after moving to Amazon EC2 instance running Ubuntu 12.04
Check your node --version s. On my Mac, homebrew installed v0.10.12 but on the server I was running v0.11.8-pre (by mistake). Apparently the present node-apn doesn't work under the unstable. I had this same extremely frustrating issue and hunted among firewalls/OpenSSH stuff until I realized the APNS connection still worked through PHP. The Ray Wenderlich script is a quick way to check if the problem is with node or elsewhere.

Categories : Node Js

Running a .py script from bash, how can I pass a python variable back to the terminal once the .py is done running?
You can write your variable and its value into an ini file from the python script. In Values.ini file my_var="value" After executing python script, just invoke Values.ini using . operator . Values.ini Now your shell variable $my_var will be having the assigned value. The advantage with this method is that you can assign any number of variables like this. var1="value1" var2="value2" var3="value3"

Categories : Python

Running pig script gives the error as: job has failed. Stop running all dependent jobs
After some research, I found that the problem here is LeaseExpiredException. This might be because the output of mapper was removed. One of the reason for this might be due to the quota allocated for the user. In my case, I was running this script in a very large data, and my quota was insufficient to process/store the data. We can check the quota by the following command: hadoop fs -count -q /user/username Thank you.

Categories : Hadoop

Running python script on crontab is causing permissions errors but running via terminal is fine
@Lucas Ou-Yang @Hyperboreus as Hyperboreus said it depends on the user privilege who run it . i think that if you give the /tmp/ dir a 777 permission from the root account it'll be fixed : chmod 777 -R /tmp/ okay try with : chmod 777 /tmp/ if the error still check if the directory /tmp/ exist !

Categories : Python

Re-installing Linux O.S. and then running bunch of commands in a .sh script , how to stop the script if something fails?
You can check the error code from commands you run #!/bin/bash function test { "$@" status=$? if [ $status -ne 0 ]; then echo "error with $1" exit 255 fi return $status } test ls test ps -ef test not_a_command taken from here for more information Bash Beginner Check Exit Status

Categories : Linux

sys module giving different output when running Python script through IDLE and by double-clicking the script
print os.path.dirname(sys.executable) is what you should use. When you click it it is probably running through python.exe so you are removing the extra char from the w.

Categories : Python

How to run a script that it has to connect 3 solaris servers, do some operations and create files in the machine where the script is running?
Use sshfs to mount the needed directories of your three servers. Afterwards you can run the script locally accessing the remote data as local files.

Categories : Bash

Cron not running Python script is script not in home folder
cron is running crontab(5) entries from the home directory of the user. You need to change appropriately the directory i.e. to call the chdir(2) syscall (either thru the cd shell builtin, or inside your python script using os.chdir). You should query the current directory (using getcwd(3), or the pwd command, or the os.getcwd in Python) in your script. Also check your PATH if running commands.

Categories : Python

error with global name when running a script from another script - python
This is a pretty interesting problem. First a quick workaround, you can provide dictionaries to use as the local and global namespace when calling execfile(), using an empty dictionary for globals works fine: # test_fun1.py a = 1 def test1(): print a execfile('test_fun2.py', {}) test1() Alternatively, if you want the code to execute within the global scope of your module you can use globals() instead of {}. Now on to why this isn't working... from the documentation on execfile(): If both dictionaries are omitted, the expression is executed in the environment where execfile() is called. Here "both dictionaries" is referring to the optional globals and locals arguments to execfile(). In this case "the environment where execfile() is called" is the local scope of the fun

Categories : Python

Running a variable script with parameters through a script
If you do this: #!/bin/sh for app in "$@"; do sh "jboss-$app" restart done Then you can pass a space-separated list of app names to the script ./restart-apps app1 app2 app3 ...

Categories : Shell

When running Python's pdb as a script, how do I autostart the script?
that's probably not the way to do to it. you should modify/extend the existing pdb.py. the code looks like this: while True: try: pdb._runscript(mainpyfile) if pdb._user_requested_quit: break print "The program finished and will be restarted" except: traceback.print_exc() print "Uncaught exception. Entering post mortem debugging" print "Running 'cont' or 'step' will restart the program" t = sys.exc_info()[2] pdb.interaction(None, t) print "Post mortem debugger finished. The "+mainpyfile+" will be restarted" it looks like you could replace `pdb._runscript(mainpyfile)' with something like runpy.run_module(sys.argv[0], run_name="__main__", alter_sys=True) (from PEP 338). not a complete solutio

Categories : Python

[three.js]: script running in IE10, not running as HTA
Okay, problem understood... solution is tricky. When using Three.js code within an HTML application (HTA), then the HTA uses IE7 quicks mode by default. You can easily add the following line to the Three.js HTA: <meta http-equiv="X-UA-Compatible" content="IE=IE10" /> But then, no more HTA mark-up is understood (windowstate, applicationname - to mention just a few) since the MS IE team wants to "focus more on standards" :-( But there is a trick which works... Create an empty HTA using all the mark-up code that you like, for example: <hta:application windowstate="minimize" border="none" icon="myIcon.ico" /> Do NOT use the IE10 X-UA-Compatible meta statement here. Create an onload javascript function within that HTA that loads the THREE.js HTML page to document.location.

Categories : Internet Explorer

Running node on EC2
This is a setup for a Linux VM where I run a MEAN app. I run my node application on a non-privileged port (>= 1024) on my VM. I use an Upstart/Monit combo to start it and keep it running. You can check out this blog post about how to set it up. For the port 80 traffic I use NGINX as a reverse proxy to my node aplication. NGINX will allow you to route the incoming traffic based on the incoming URL. Here is link to a good SO page on how to set that part up.

Categories : Node Js

Running Node.js app with Ruby app together
Kramdown is a parser gem, and like bundler it can be called from commandline. Kramdown takes markdown or any of its superset as an input parameter and spits out html/latex/kramdown as o/p. Without any options the default output is HTML and that's the desired o/p in this case. So we just need to call kramdown from shell from the node.js app (if kramdown gem is installed, if not $gem install kramdown). Here is what I guess it should be done in node.js. (I have zero knowledge in node.js, if there is something like ffi available to interface with ruby? if so its the better option than calling it from shell). var util = require('util'), exec = require('child_process').exec, child; child = exec('kramdown '+markdownFile, // command line argument directly in string function

Categories : Ruby

pdf.js running hello world in node app
I tried your code without disableWorker=true, because otherwise the promise never gets called, and also included pdf.worker.js in the project (the other file generated by node make generic) so I don't get .workerSrc error (what was it exactly?). Also the PDFDoc constructor seems to be obsolete in the version of pdf.js I'm using - 0.8.0. Making these changes the PDF is loaded fine.

Categories : Javascript

running a server file on node.js
When you close the terminal, everything that runs in it is killed. There are many solutions on both Linux and Windows systems, most of them create some sort of a service which then runs in the background. Here are some possible solutions: http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever https://github.com/indexzero/daemon.node http://www.coretechnologies.com/products/AlwaysUp/Apps/RunNodeJSAsAService.html http://coreybutler.github.io/node-windows/manual/#!/api/nodewindows.Service Pick the one that is best for you. Related question on StackOverflow: How to run node.js app forever when console is closed?

Categories : Node Js

Running EJB timer on each node in a cluster
Yes, you want a non-persistent timer. Per the EJB 3.1 specification: Non-persistent timers can be created programmatically or automatically (using @Schedule or the deployment descriptor). For automatic non-persistent timers, the container creates a new non-persistent timer during application initialization for each JVM across which the container is distributed. (As an aside, Derby databases can only be shared by multiple processes if you use Derby network server. Multiple application server processes cannot open a Derby database simultaneously.)

Categories : Java

running my sample app using express.js and node.js
You can put the files wherever you like, so long as the user the server is running as can read them. If you want that code to serve them, however, then you will need to replace all the response.* code you have with code that will: Identify which file is being requested based on the data in request Determine if that file exists (and send a 404 response if it does not) Determine the correct content type for that file type and set the header appropriately Read the file in and output it in the response In other words: Node.js is not a web server. You can write a web server in JavaScript and run it on Node.js, but you've only taken the very first steps along that route.

Categories : Javascript

Error running Node.js app on Heroku
That demo isn't a node app, or atleast isn't packaged the way heroku likes it with a Procfile and everything. If you have a node app, then it would server the static files as per it's code (or atleast it should), but heroku isn't a standard web server for static pages (like Apache or nginx or whatever). Heroku was built to run web apps, which are essentially their own servers. If you get a node server running, this heroku quickstart for node should help you out. https://devcenter.heroku.com/articles/nodejs

Categories : Node Js

running custom functions with node and socket.io
You are converting data to an array and then try to call a property it doesn't have anymore then applying the data to the socket.on function (this) so try something like: socket.on('runFunction', function(data) { var arg = []; args.push(data.id); args.push(data.name); // etc... data.callback.apply(this, args); });

Categories : Javascript

Error running foreman to fire up a Node.js app
If you are following a guide specifically for use on a Heroku instance then it will skip some steps that will be required for setting up on other boxes. By default heroku instances have node.js installed, so there is no need to get this set up on the box prior to deploying and launching your first application. To install Node.js on Linux Mint. Do the following: Install required tools sudo apt-get install g++ curl libssl-dev apache2-utils sudo apt-get install git-core Clone and make latest version of Node.js git clone git://github.com/ry/node.git cd node ./configure make sudo make install Go to your working directory for this project and run the following: npm install foreman start Your Node.js application example should now be working on your local VM. To get a sample node a

Categories : Node Js

running multiple files on node js at the same time
This is normal behavior. Node will only exit if there's nothing more to do (or if you manually stop it via Ctrl+C). Since you told http to listen(), the process will stay alive indefinitely. It's not exactly clear what you're asking, but if you want to run additional files inside your app, you simply require() them. var otherFile = require('./otherFile.js') // the .js is optional otherFile will now be set to whatever you do to module.exports in otherFile.js. You should read the module documentation to get a full understanding of how require works. If you want to run other unrelated files with node at the same time, open a separate command prompt window. I will now read between the lines a little: it looks like you might be wondering how to get http to serve files from disk like

Categories : Javascript

neo4j 2.0 not creating node but running successfully
Make sure your Web Admin is pointing to the same place as the DB_PATH in your code. You can find the Web Admin properties in conf/neo4j-server.properties of your neo4j directory

Categories : Java

Why does BFS gives different running time for different node positions in same graph?
First of all: did you run it multiple times? Results might vary quite a lot. Anyways, there is a good chance that it is because of caching issues. Computers usually work quite well when you access an array from 0, because they immediately cache (a part of) the array from the index you are accessing. But if you start from the end of the array, it will not have the entire array in a fast cache. (this is no different for a vector, since a vector is simply a dynamically size able array) Also, you should not test algorithm speed this way, you can't really compare them like this. Because if you first run BFS, it has simply not yet cached the entire array. But when you have ran DFS, the entire array is probably in a fast cache for the processor. I would recommend taking a larger graph and check

Categories : C++

How to switch app.js to app2.js running on node server?
(Assuming you're using Express) You can create some middleware that checks if the user is authenticated. If they are, it forwards the request; otherwise, it does whatever it needs. See app.use in the documentation for more information. It turns out that if you want to apply middleware to specific routes, you can; just pass the middleware as additional arguments after the path and before the main handler.

Categories : Node Js

Is it possible to debug a currently running production Node application?
Yes, you just need to follow a few steps from node inspector's README: node-inspector has to be running on the machine with the node process you are trying to debug. So, you must be able to install this there. Presumably your production process did not start with the --debug flag. You can send a signal to achieve this though: kill -s USR1 <pid>. (pid can be obtained with something like ps aux | grep node.) Make sure port 8080 is exposed to your local machine from your production machine. Point your browser as normal; you're all set up.

Categories : Node Js

Node JS fs.createReadStream running browser out of memory
After fixing a number of logic errors in your script and wrapping it under a default express server, I find no appreciable increase in memory while transfering a 2.2GB file from server to client. I ran with both socket.volatile.send() and socket.volatile.emit() with no discernible difference in speed. Server: node.js v0.8.6 on Fedora release 11 (Leonidas) Client: Google Chrome Version 28.0.1500.95 m Server Source: app.js /** * Module dependencies. */ var express=require('express'), app=express(), http=require('http'), server=http.createServer(app), io=require('socket.io').listen(server), routes=require('./routes'), user=require('./routes/user'), path=require('path'), fs=require('fs'); // all environments -- express defaults app.set('port', process.e

Categories : Javascript

Running a Grunt Task directly from Node
Update While this is the answer, Grunt has tons of issues with being run directly from Node. Not the least of which is when the grunt task fails, it calls process.exit and nicely quits your node instance. I cannot recommend trying to get this to work. Ok, I'll just answer my own question. I was right, the command I had was wrong. Updated code: var grunt = require('grunt'); grunt.registerTask('default', 'Log some stuff.', function() { console.log('stuff'); }); grunt.tasks(['default']);

Categories : Javascript

Running console commands through node inspector?
The reason why it doesn't work as you expected is that all your variables and functions are local to your module (application) and you can't access them from a global context. You can save them in the global scope if you want to access them from anywhere (including from the console when not stopped on a breakpoint): var express = require('express'); var app = express(); function test() { console.log('yo'); } app.listen(3000); global.test = test;

Categories : Node Js

Running a PHP script
What you need to do is to fork the process before you terminate it. This way when you exit the process (or close your ssh connection) the secondary process will continue to run. $pid = pcntl_fork(); if ($pid == -1) { die('could not fork'); } else if ($pid) { // parent pcntl_wait($status); } else { // child // write your code here! }

Categories : PHP

running pig script
I have not used node.js. But here I find a link to show how to execute a unit command in node.js: http://www.dzone.com/snippets/execute-unix-command-nodejs For example, if you want to run a pig script called foo.pig. Then you can try the following code: var sys = require('sys') var exec = require('child_process').exec; function puts(error, stdout, stderr) { sys.puts(stdout) } exec("pig -f foo.pig", puts); You can replace pig -f foo.pig to any command that you use to run your pig script.

Categories : Node Js

Don't run script if it's already running
Try using ignore_user_abort(true); it will continue to run even if the person leaves and closes the browser. you might also want to put a number instead of true false in the db record and set a maximum number of processes that can run together

Categories : PHP

Running Grunt and Node as batch files through cron
Of course, the one thing I didn't check. I had to include the path to the node and grunt executables in the batch file. Despite the fact that I don't have to do that when logged in, and it's the same user running the cron jobs.

Categories : Node Js

Running a forward proxy server in nodejitsu using node js
You can write a simple proxy using the request module, like this: var http = require('http'), request = require('request'); // For nodejitsu, this will be port 80 externally var port = process.env.PORT || 8000; http.createServer(function(req,res) { req.pipe(request(req.url)).pipe(res) }).listen(port); However, this will only work with http, not https. Nodejitsu also produces a proxy module, you may get some ideas on what to do next by looking at that.

Categories : Node Js

What is a good hosting solution for running node.js with R / Rserve?
http://prgmr.com/xen/ I currently use this solution to run my Node.js server and it's currently great. They have wonderful support and they're uptime is 100%. I cannot recommend this any higher, but you will need to know how to set up a simple OS and run it from the ground up. For example, if you want to run a server without having it stop when you close the SSH connection, you would use screen node script.js and press [control] + [A] + [D] keys. You might already know this, so simply take my advice and view the website.

Categories : R

Receiving data sent from AIR app in node.js server running on Heroku
It seems it only does not work on the Simulator, once on testing on a real device it will work with the URL given by Heroku. Still don't know how to make it work on the Simulator though.

Categories : Node Js

Running a php script with a .bat file
The START command optionally accepts a title for the created window as its first argument; in this case, it thinks that C:Program Files (x86)PHPv5.3php.exe is the title to display and -f (the second argument) is the executable you want to run. You can therefore fix this by providing a placeholder title, e.g. start "email reminder task" "C:Program Files (x86)PHPv5.3php.exe" -f C:inetpubwwwrootsitenamecrons eminder-email.php Or, preferably, you can ditch the START command altogether (you aren't using any of its unique facilities) and just run PHP directly: "C:Program Files (x86)PHPv5.3php.exe" -f C:inetpubwwwrootsitenamecrons eminder-email.php

Categories : PHP

Running a script for certain days
Put this in your crontab: */20 * * * * bash /path/to/your/script.sh Then remove it after 10 days. Better yet, have your script check the current date and send you an email when it's 10 days from now to remind you to remove it. You could also just have the script remove the line from the crontab (or just remove the crontab file if it's only got this one line) after 10 days.

Categories : PHP



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