Daily Archives

Articles indexed Friday November 8 2013

Page 8/17 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • cannot evaluate expression because a native frame is on top of the call stack and system.accessviolationexception

    - by Joseph
    I have this code using c#. public partial class MainForm : Form { private CvCapture VideoCapture; private IplImage frame; private IplImage imgMain; public MainForm() { InitializeComponent(); } private void btnVideo_Click(object sender, EventArgs e) { double vidWidth, vidHeight; try { VideoCapture = highgui.CvCreateCameraCapture(0); } catch (Exception except) { MessageBox.Show(except.Message); } if (btnVideo.Text.CompareTo("Start Video") == 0) { if (VideoCapture.ptr == IntPtr.Zero) { MessageBox.Show("badtrip ah!!!"); return; } btnVideo.Text = "Stop Video"; highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH, 640); highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT, 480); highgui.CvQueryFrame(ref VideoCapture); vidWidth = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH); vidHeight = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT); picBoxMain.Width = (int)vidWidth; picBoxMain.Height = (int)vidHeight; timerGrab.Enabled = true; timerGrab.Interval = 42; timerGrab.Start(); } else { btnVideo.Text = "Start Video"; timerGrab.Enabled = false; if (VideoCapture.ptr == IntPtr.Zero) { highgui.CvReleaseCapture(ref VideoCapture); VideoCapture.ptr = IntPtr.Zero; } } } private void timerGrab_Tick(object sender, EventArgs e) { try { frame = highgui.CvQueryFrame(ref VideoCapture); if (frame.ptr == IntPtr.Zero) { timerGrab.Stop(); MessageBox.Show("??"); return; } imgMain = cxcore.CvCreateImage(cxcore.CvGetSize(ref frame), 8, 3); picBoxMain.Image = highgui.ToBitmap(imgMain, false); cxcore.CvReleaseImage(ref imgMain); //cxcore.CvReleaseImage(ref frame); } catch (Exception excpt) { MessageBox.Show(excpt.Message); } } } The problem is after i break all and step through the debugger the program stops at a certain code. the code where it stops is here: frame = highgui.CvQueryFrame(ref VideoCapture); the error is that it says that cannot evaluate expression because a native frame is on top of the call stack. and then when i try to shift+F11 it. there is another error saying that system.accessviolationexception. the stack trace says that: at System.Runtime.InteropServices.Marshal.CopyToManaged(IntPtr source, Object destination, Int32 startIndex, Int32 length) at CxCore.IplImage.get_ImageDataDb()

    Read the article

  • Access to the path C:\... is denied?

    - by user2969489
    I've created a simple download manager with two textboxes and two buttons, one for download and one for specifying the path where i want to save the downloaded file... (folderBrowserDialog1.SelectedPath;) But when i specify the path that the file is going to be saved, it requires me to specify the type too like C:\Users\Me\Desktop\photo.jpg...When i leave it without \photo.jpg it shows C:\Users\Me\Desktop' is denied. I want that automatically to detect the extension and not to write \photo.jpg, bmp...everytime. Thanks.

    Read the article

  • Clickonce program will not start when launched from shell_execute

    - by Brandon
    I have a very old program that I have no control over. It launches a filetype with its default application like this(I cannot modify this code): LET Err (SHELL_EXECUTE 'open' (FIX_MESG '"{1}"' File_name) '' '') ^^The above code works, so long as that filetype isn't associated with ClickOnce. The old program is 32 bit, the OS is Windows 7 64 bit. I can compile my clickonce program as anything, but none seem to work. (I've tried x84, x64 and anyCPU) How can I make a 32 bit program use shell execute to launch a ClickOnce program on a 64bit OS?

    Read the article

  • Permanent access token to an app that posts to a fan page - error code:1

    - by Leandro Guedes
    I'm following the steps very well described here http://stackoverflow.com/a/18399927/2510225 , but, from my server, I receive the following error: {"error":{"message":"The access token does not belong to application APP-ID","type":"OAuthException","code":1}} I can't figure what I'm doing wrong. Anyone knows if the process to get a permanent access token has changed, or is having the same issue? The access token I'm using in the request is the user access token, which I think is correct.

    Read the article

  • bad request error 400 while using python requests.post function

    - by Toussah
    I'm trying to make a simple post request via the requests library of Python and I get a bad request error (400) while my url is supposedly correct since I can use it to perform a get. I'm very new in REST requests, I read many tutorials and documentation but I guess there are still things I don't get so my error could be basic. Maybe a lack of understanding on the type of url I'm supposed to send via POST. Here my code : import requests v_username = "username" v_password = "password" v_headers = {'content-type':'application/rdf+xml'} url = 'https://my.url' params = {'param': 'val_param'} payload = {'data': 'my_data'} r = requests.post(url, params = params, auth=(v_username, v_password), data=payload, headers=v_headers, verify=False) print r I used the example of the requests documentation.

    Read the article

  • If statements Evaluations

    - by user2464795
    Using the code below I get this result even though I put in a number that is greater than 18. run: How old are you? 21 You have not reached the age of Majority yet! BUILD SUCCESSFUL (total time: 3 seconds) I am new to java and trying to self learn can anybody help? import java.util.Scanner; public class Chapter8 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner reader = new Scanner (System.in); // TODO code application logic here //Excercise 15 System.out.print("How old are you? "); int x = Integer.parseInt(reader.nextLine()); if (x > 18){ System.out.println("You have not reached the age of Majority yet!"); }else { System.out.println("You have reached the age of Majority!"); }

    Read the article

  • Ruby/ROR Symbols Clarification

    - by Jelani Thompson
    I'm new to Ruby/ROR and I'm kind of confused with something. A simple explanation would help. Say I was linking to another page in Ruby on Rails. Would the keyword link_to be considered a method? Also, if so, where would I be able to learn more about these? Symbols. What is the difference between a symbol with a colon on the :left or a symbol with a colon on the right:? Where would I be able to learn more about these?

    Read the article

  • C++ Eclipse error class mynamespace::mynamespace

    - by user2969329
    I'm new to C++, coming from a Java and web programming background. I specified a header file, with class definition. The class and the namespace have the same name. I do not know if that causes this issue, eclipse is very unspecific. Here is the World.h file: `/* * World.h * * Created on: 5 nov. 2013 * Author: Mo */ #ifndef WORLD_H_ #define WORLD_H_ #include "../../lib/tinyxml/tinyxml.h" #include "Layer.h" namespace World { class World { private: Layer layers[]; public: World(); virtual ~World(); TiXmlElement toXML(); }; } /* namespace World */ #endif /* WORLD_H_ */` The error occurs in the class definition. The only thing eclipse shows is: class World::World I have been googling for the last day and a half, and haven't found anything similar. In other classes, World is not seen as a type: "World" does not name a type. What have I done wrong? Help would be greatly appreciated.

    Read the article

  • Extracting specific nodes from XML using XML::Twig

    - by pratz
    i was trying to extract a particular set of nodes from the following XML structure using XML::Twig, but have been stuck ever since. I need to extract the 'player' nodes from the following structure and do a string match/replace on each of these node values. <pep:record> <agency> <subrecord type="scout"> <isnum>123XXX (print)</isnum> <isnum>234YYY (mag)</isnum> </subrecord> <subrecord type="group"> </subrecord> </agency </record> I tried using the following code, but I get pointed to a hash reference rather than actual string. my $parser = XML::Twig->new(twig_handlers => { isnum => sub { print $_->text."::" }, }); foreach my $rec (split(/::/, $parser->parse($my_xml))) { if ($rec =~ m/print/) { ($print = $rec) =~ s/( \(print\))//; } elsif($rec =~ m/mag/) { ($mag = $rec) =~ s/( \(mag\))//; } }

    Read the article

  • Get the UIWindow which is under the UIActionSheet

    - by Georgi
    I am trying to present a new UIViewController on top of the current current UIViewController. Here is the line of code that creates the desired effect: LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; UIViewController *rootController = [[[UIApplication sharedApplication] keyWindow] rootViewController]; [rootController presentViewController:loginViewController animated:YES completion:nil]; The problem is that I added an UIActionSheet which asks the user to confirm the desired action (which is to log out). When the user confirms the action I run the above mentioned peace of code, but the UIActionSheet is still the keyWindow. Therefore the LoginViewController is not presented on top (the rootController is null when I try to debug). My question is: Can I somehow find the UIWindow which is under the UIActionSheet and from there get the root controller,or maybe I can dismiss programmatically the UIActionSheet when the users selects the log out action and only then execute the above code? Thank you in advance!

    Read the article

  • Why is this undefined behaviour?

    - by xryl669
    Here's the sample code: X * makeX(int index) { return new X(index); } struct Tmp { mutable int count; Tmp() : count(0) {} const X ** getX() const { static const X* x[] = { makeX(count++), makeX(count++) }; return x; } }; This reports Undefined Behaviour on CLang version 500 in the static array construction. For sake of simplication for this post, the count is not static, but it does not change anything.

    Read the article

  • Debugging Post Request with Chrome Dev Tools

    - by benek
    I am trying to use Chrome Dev for debugging the following Angular post request : $http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader) After running the statement with right-click / evaluate, I can see the post in the network panel with a pending state. How can I get the result or "commit" the request and leave easily this "pending" state from the dev console ? I am not yet very familiar with JS callbacks, some code is expected. Thanks. EDIT I have tried to run from the console : $scope.$apply(function(){$http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader).success(function(data){console.log("error "+data)}).error(function(data){console.log("error "+data)})}) It returns : undefined EDIT The post I am trying to solve generate an HTTP 400. Here is the result : Request URL:http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader Request Method:POST Status Code:400 Mauvaise Requ?te Request Headersview source Accept:application/json, text/plain, / Accept-Encoding:gzip,deflate,sdch Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 Connection:keep-alive Content-Length:5354 Content-Type:application/json;charset=UTF-8 Cookie:JSESSIONID=285AF523EA18C0D7F9D581CDB2286C56 Host:picjboss.puma.lan:8880 Origin:http://picjboss.puma.lan:8880 Referer:http://picjboss.puma.lan:8880/fluxpousse/ User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 X-Requested-With:XMLHttpRequest Request Payloadview source {refHeader:IDSFP, idEntrepot:619, codeEntreprise:null, codeBanniere:null, codeArticle:7,…} cessionPrice: 78 codeArticle: "7" codeBanniere: null codeDateAppro: null codeDateDelivery: null codeDatePrepa: null codeEntreprise: null codeFournisseur: null codeUtilisateur: null codeUtilisateurLastUpdate: null createDate: null dateAppro: null dateDelivery: null datePrepa: null hasAssortControl: null hasCadenceForce: null idEntrepot: 619 isFreeCost: null labelArticle: "Mayonnaise de DIJON" labelFournisseur: null listDetail: [,…] pcbArticle: 12 pvc: 78 qte: 78 refCommande: "ref" refHeader: "IDSFP" state: "CREATED" stockArticle: 1200 updateDate: null Response Headersview source Connection:close Content-Length:996 Content-Type:text/html;charset=utf-8 Date:Fri, 08 Nov 2013 15:19:30 GMT Server:Apache-Coyote/1.1 X-Powered-By:Servlet 2.5; JBoss-5.0/JBossWeb-2.1

    Read the article

  • Search for a pattern in a list of strings - Python

    - by Holtz
    I have a list of strings containing filenames such as, file_names = ['filei.txt','filej.txt','filek.txt','file2i.txt','file2j.txt','file2k.txt','file3i.txt','file3j.txt','file3k.txt'] I then remove the .txt extension using: extension = os.path.commonprefix([n[::-1] for n in file_names])[::-1] file_names_strip = [n[:-len(extension)] for n in file_names] And then return the last character of each string in the list file_names_strip: h = [n[-1:] for n in file_names_strip] Which gives h = ['i', 'j', 'k', 'i', 'j', 'k', 'i', 'j', 'k'] How can i test for a pattern of strings in h? So if i,j,k occur sequentially it would return True and False if not. I need to know this because not all file names are formatted like they are in file_names. So: test_ijk_pattern(h) = True no_pattern = ['1','2','3','1','2','3','1','2','3'] test_ijk_pattern(no_pattern) = False

    Read the article

  • RestKit : Not able to perform mapping using coredata

    - by Ashish Beuwria
    I'm using rest kit 0.20.3 and Xcode 5. Without core data I'm able to perform all rest kit operation, but when I've tried it with core data, I'm not even able to perform GET due to some problem. I can't figure it out. I'm new with core data. So pls help. Here is my code: AppDelegate.m @implementation CardGameAppDelegate @synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RKLogConfigureByName("RestKit", RKLogLevelWarning); RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace); RKLogConfigureByName("RestKit/Network", RKLogLevelTrace); RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://192.168.1.3:3010/"]]; RKManagedObjectStore *objectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:self.managedObjectModel]; objectManager.managedObjectStore = objectStore; RKEntityMapping *playerMapping = [RKEntityMapping mappingForEntityForName:@"Player" inManagedObjectStore:objectStore]; [playerMapping addAttributeMappingsFromDictionary:@{@"id": @"playerId", @"name": @"playerName", @"age" : @"playerAge", @"created_at": @"createdAt", @"updated_at": @"updatedAt"}]; RKResponseDescriptor *responseDesc = [RKResponseDescriptor responseDescriptorWithMapping:playerMapping method:RKRequestMethodGET pathPattern:@"/players.json" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [objectManager addResponseDescriptor:responseDesc]; PlayersTableViewController *ptvc = (PlayersTableViewController *)self.window.rootViewController; ptvc.managedObjectContext = self.managedObjectContext; return YES; } and code for playerTableViewController.h #import <UIKit/UIKit.h> @interface PlayersTableViewController : UITableViewController <NSFetchedResultsControllerDelegate> @property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController; @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext; @end and PlayerTableViewController.m get method: -(void)loadPlayers{ [[RKObjectManager sharedManager] getObjectsAtPath:@"/players.json" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){ [self.refreshControl endRefreshing]; } failure:^(RKObjectRequestOperation *operation, NSError *error) { [self.refreshControl endRefreshing]; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An Error Has Occurred" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; }]; } I'm getting the following error : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to perform mapping: No `managedObjectContext` assigned. (Mapping response.URL = http://192.168.1.3:3010/players.json)'

    Read the article

  • Why don't I need to bind my vertex buffer object before calling glDrawArrays?

    - by valmo
    I'm a bit confused why this still renders. I thought you need to bind a vertex buffer object so that glDrawArrays knows which vertex buffer to use. Here is my initialisation code.. // Create and bind vertex array to store vertex attribute states. glGenVertexArraysOES(NUM_VERTEX_ARRAYS, &m_vertexArray); glBindVertexArrayOES(m_vertexArray); // Create and bind vertex buffer to store vertex data. glGenBuffers(NUM_VERTEX_BUFFERS, &m_vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * 36, &m_vertices[0], GL_STATIC_DRAW); glEnableVertexAttribArray(VertexAttribPosition); glVertexAttribPointer(VertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0)); glEnableVertexAttribArray(VertexAttribNormal); glVertexAttribPointer(VertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12)); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArrayOES(0); Here is my render code. I'm confused why glDrawArrays still works when I bind 0 to GL_ARRAY_BUFFER. glBindVertexArrayOES(m_vertexArray); glBindBuffer(GL_ARRAY_BUFFER, 0); glDrawArrays(GL_TRIANGLES, 0, 36); glBindVertexArrayOES(0);

    Read the article

  • Injecting correct object graph using StructureMap in Queue of different Objects

    - by davy
    I have a queuing service that has to inject a different dependency graph depending on the type of object in the queue. I'm using Structure Map. So, if the object in the queue is TypeA the concrete classes for TypeA are used and if it's TypeB, the concrete classes for TypeB are used. I'd like to avoid code in the queue like: if (typeA) { // setup TypeA graph } else if (typeB) { // setup TypeB graph } Within the graph, I also have a generic classes such as an IReader(ISomething, ISpomethingElse) where IReader is generic but needs to inject the correct ISomething and ISomethingElse for the type. ISomething will also have dependencies and so on. Currently I create a TypeA or TypeB object and inject a generic Processor class using StructureMap into it and then pass a factory manually inject a TypeA or TypeB factory into a method like: Processor.Process(new TypeAFactory) // perhaps I should have an abstract factory... However, because the factory then creates the generic IReader mentioned above, I end up manually injecting all the TypeA or TypeB classes fro there on. I hope enough of this makes sense. I am new to StructureMap and was hoping somebody could point me in the right direction here for a flexible and elegant solution. Thanks

    Read the article

  • Strip tags (with tags inside attributes and nested tags) using javascript

    - by Kokizzu
    What the fastest (in performance) way to strip strings from tags, most solution i've tried that uses regexp not resulting correct values for tags inside attributes (yes, i know it's wrong), example test case: var str = "<div data-content='yo! press this: <br/> <button type=\"button\"><i class=\"glyphicon glyphicon-disk\"></i> Save</button>' data-title='<div>this one for tooltips <div>seriously</div></div>'> this is the real content<div> with another nested</div></div>" that should resulting: this is the real content with another nested

    Read the article

  • Which is the fastest idiomatic way to add all vectors (in the math sense) inside a Scala list?

    - by davips
    I have two solutions, but one doesn't compile and the other, I think, could be better: object Foo extends App { val vectors = List(List(1,2,3), List(2,2,3), List(1,2,2)) //just a stupid example //transposing println("vectors = " + vectors.transpose.map (_.sum)) //it prints vectors = List(4, 6, 8) //folding vectors.reduce { case (a, b) => (a zip b) map { case (x, y) => x + y } } //compiler says: missing parameter type for exp. function; arg. types must be fully known }

    Read the article

  • Centering ToggleButton Image - With No Text

    - by KickingLettuce
    Here is my ToggleButton: <ToggleButton android:id="@+id/bSmenuTopItems" android:layout_width="wrap_content" android:layout_height="48dp" android:background="@drawable/master_button_selector" android:drawableLeft="@drawable/flame_icon" /> I have no text in this image, I need a ToggleButton due to Active State. EDIT: I think question was misunderstood. There is a drawable inside the Toggle Button (flame_icon) and it is set as background. I want it to be centered. There is no Text, just an image. I need a Toggle Button because I need to have an Active State when selected. There is only drawableLeft, drawableRight, drawableTop, etc. I want a draweableMiddle that doesn't seem to exisit.

    Read the article

  • Reading a file over a network path

    - by Sin5k4
    I have this weird issue,when I use > File FileToRead = new File("\\\\MYSERVER\\MYFOLDER\\MYFOLDER\\MYPICTURE.JPG"); to read a file over a network,all I get is a null pointer exception.Normally a local path works with this,but when on a network path,I just couldn't manage to get it to work.Any ideas? PS:oh and my network connection seems to work,no issues when accessing data in windows explorer... More of the code: File FileToRead = new File("file://DOKSERVICE/Somefolder/ProductImage/01001.JPG"); // File FileToRead = new File("c:\\dog.jpg"); local test BufferedImage image = ImageIO.read(FileToRead); BufferedImage resizedimage = new BufferedImage(260, 260,BufferedImage.TYPE_INT_RGB ); Graphics2D g = resizedimage.createGraphics(); g.drawImage(image, 0, 0, 260, 260, null); g.dispose(); picture.setIcon(new ImageIcon(image));

    Read the article

  • puma init.d for centos 6 fails with runuser: user /var/log/puma.log does not exist

    - by Rubytastic
    Trying to get a init.d/puma to work on Centos 6. It throws error runuser: user /var/log/puma.log does not exist I run this from the /srv/books/current folder but it fails. I tried to debug the values but not quite get what is missing and why it throws this error. #! /bin/sh # puma - this script starts and stops the puma daemon # # chkconfig: - 85 15 # description: Puma # processname: puma # config: /etc/puma.conf # pidfile: /srv/books/current/tmp/pids/puma.pid # Author: Darío Javier Cravero &lt;[email protected]> # # Do NOT "set -e" # Original script https://github.com/puma/puma/blob/master/tools/jungle/puma # It was modified here by Stanislaw Pankevich <[email protected]> # to run on CentOS 5.5 boxes. # Script works perfectly on CentOS 5: script uses its native daemon(). # Puma is being stopped/restarted by sending signals, control app is not used. # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/usr/local/bin:/usr/local/sbin/:/sbin:/usr/sbin:/bin:/usr/bin DESC="Puma rack web server" NAME=puma DAEMON=$NAME SCRIPTNAME=/etc/init.d/$NAME CONFIG=/etc/puma.conf JUNGLE=`cat $CONFIG` RUNPUMA=/usr/local/bin/run-puma # Skipping the following non-CentOS string # Load the VERBOSE setting and other rcS variables # . /lib/init/vars.sh # CentOS does not have these functions natively log_daemon_msg() { echo "$@"; } log_end_msg() { [ $1 -eq 0 ] && RES=OK; logger ${RES:=FAIL}; } # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that performs a clean up of puma.* files # cleanup() { echo "Cleaning up puma temporary files..." echo $1; PIDFILE=$1/tmp/puma/puma.pid STATEFILE=$1/tmp/puma/puma.state SOCKFILE=$1/tmp/puma/puma.sock rm -f $PIDFILE $STATEFILE $SOCKFILE } # # Function that starts the jungle # do_start() { log_daemon_msg "=> Running the jungle..." for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` user=`echo $i | cut -d , -f 2` config_file=`echo $i | cut -d , -f 3` if [ "$config_file" = "" ]; then config_file="$dir/puma/config.rb" fi log_file=`echo $i | cut -d , -f 4` if [ "$log_file" = "" ]; then log_file="$dir/puma/puma.log" fi do_start_one $dir $user $config_file $log_file done } do_start_one() { PIDFILE=$1/puma/puma.pid if [ -e $PIDFILE ]; then PID=`cat $PIDFILE` # If the puma isn't running, run it, otherwise restart it. if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then do_start_one_do $1 $2 $3 $4 else do_restart_one $1 fi else do_start_one_do $1 $2 $3 $4 fi } do_start_one_do() { log_daemon_msg "--> Woke up puma $1" log_daemon_msg "user $2" log_daemon_msg "log to $4" cleanup $1; daemon --user $2 $RUNPUMA $1 $3 $4 } # # Function that stops the jungle # do_stop() { log_daemon_msg "=> Putting all the beasts to bed..." for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` do_stop_one $dir done } # # Function that stops the daemon/service # do_stop_one() { log_daemon_msg "--> Stopping $1" PIDFILE=$1/tmp/puma/puma.pid STATEFILE=$1/tmp/puma/puma.state echo $PIDFILE if [ -e $PIDFILE ]; then PID=`cat $PIDFILE` echo "Pid:" echo $PID if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then log_daemon_msg "---> Puma $1 isn't running." else log_daemon_msg "---> About to kill PID `cat $PIDFILE`" # pumactl --state $STATEFILE stop # Many daemons don't delete their pidfiles when they exit. kill -9 $PID fi cleanup $1 else log_daemon_msg "---> No puma here..." fi return 0 } # # Function that restarts the jungle # do_restart() { for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` do_restart_one $dir done } # # Function that sends a SIGUSR2 to the daemon/service # do_restart_one() { PIDFILE=$1/tmp/puma/puma.pid i=`grep $1 $CONFIG` dir=`echo $i | cut -d , -f 1` if [ -e $PIDFILE ]; then log_daemon_msg "--> About to restart puma $1" # pumactl --state $dir/tmp/puma/state restart kill -s USR2 `cat $PIDFILE` # TODO Check if process exist else log_daemon_msg "--> Your puma was never playing... Let's get it out there first" user=`echo $i | cut -d , -f 2` config_file=`echo $i | cut -d , -f 3` if [ "$config_file" = "" ]; then config_file="$dir/config/puma.rb" fi log_file=`echo $i | cut -d , -f 4` if [ "$log_file" = "" ]; then log_file="$dir/log/puma.log" fi do_start_one $dir $user $config_file $log_file fi return 0 } # # Function that statuss then jungle # do_status() { for i in $JUNGLE; do dir=`echo $i | cut -d , -f 1` do_status_one $dir done } # # Function that sends a SIGUSR2 to the daemon/service # do_status_one() { PIDFILE=$1/tmp/puma/pid i=`grep $1 $CONFIG` dir=`echo $i | cut -d , -f 1` if [ -e $PIDFILE ]; then log_daemon_msg "--> About to status puma $1" pumactl --state $dir/tmp/puma/state stats # kill -s USR2 `cat $PIDFILE` # TODO Check if process exist else log_daemon_msg "--> $1 isn't there :(..." fi return 0 } do_add() { str="" # App's directory if [ -d "$1" ]; then if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then str=$1 else echo "The app is already being managed. Remove it if you want to update its config." exit 1 fi else echo "The directory $1 doesn't exist." exit 1 fi # User to run it as if [ "`grep -c "^$2:" /etc/passwd`" -eq 0 ]; then echo "The user $2 doesn't exist." exit 1 else str="$str,$2" fi # Config file if [ "$3" != "" ]; then if [ -e $3 ]; then str="$str,$3" else echo "The config file $3 doesn't exist." exit 1 fi fi # Log file if [ "$4" != "" ]; then str="$str,$4" fi # Add it to the jungle echo $str >> $CONFIG log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though." } do_remove() { if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then echo "There's no app $1 to remove." else # Stop it first. do_stop_one $1 # Remove it from the config. sed -i "\\:^$1:d" $CONFIG log_daemon_msg "Removed a Puma from the jungle: $1." fi } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_start else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` user=`echo $i | cut -d , -f 2` config_file=`echo $i | cut -d , -f 3` if [ "$config_file" = "" ]; then config_file="$dir/config/puma.rb" fi log_file=`echo $i | cut -d , -f 4` if [ "$log_file" = "" ]; then log_file="$dir/log/puma.log" fi do_start_one $dir $user $config_file $log_file fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_stop else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` do_stop_one $dir fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) # TODO Implement. log_daemon_msg "Status $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_status else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` do_status_one $dir fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" if [ "$#" -eq 1 ]; then do_restart else i=`grep $2 $CONFIG` dir=`echo $i | cut -d , -f 1` do_restart_one $dir fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; add) if [ "$#" -lt 3 ]; then echo "Please, specifiy the app's directory and the user that will run it at least." echo " Usage: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log" echo " config and log are optionals." exit 1 else do_add $2 $3 $4 $5 fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; remove) if [ "$#" -lt 2 ]; then echo "Please, specifiy the app's directory to remove." exit 1 else do_remove $2 fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; *) echo "Usage:" >&2 echo " Run the jungle: $SCRIPTNAME {start|stop|status|restart}" >&2 echo " Add a Puma: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log" echo " config and log are optionals." echo " Remove a Puma: $SCRIPTNAME remove /path/to/app" echo " On a Puma: $SCRIPTNAME {start|stop|status|restart} PUMA-NAME" >&2 exit 3 ;; esac :

    Read the article

  • Gentoo/mdadm: Remove 1 disk from RAID 0 array

    - by Tim
    The server has a 7-disk RAID 0 array, and sdf is starting to die. Is there a way to remove sdf while keeping the array intact? # df -h Filesystem Size Used Avail Use% Mounted on /dev/md1 14T 6.6T 7.0T 49% /var [...] # cat /proc/mdstat Personalities : [raid0] md1 : active raid0 sda4[0] sdf1[5] sdd1[3] sdb1[1] sde1[4] sdg1[6] sdc1[2] 14482788352 blocks 512k chunks Looking to keep downtime to a minimum.

    Read the article

  • Grant user from one domain permissions to shared folder in another domain

    - by w128
    I have two computers set up like this: \\myPC (local Windows 7 SP1 machine); it is in domain1; \\remotePC (Win Server 2008 with SQL Server - a HyperV virtual machine); it is in domain2. In domain2 active directory, I have a user account RemoteAccount. I would like to give this account full permissions to a shared folder located on \\myPC, i.e. folder \\myPC\SharedFolder. The problem is, when I right-click the folder and go to sharing permissions, I can't add permissions for the domain2\RemoteAccount user, because this user cannot be found - I can only see domain1 users. When I click 'Locations' in "Select users, computers, service accounts, or groups" dialog, I only see domain1. Is there a way to do this?

    Read the article

  • mongodb : Can create new thread on FreeBSD?

    - by user197739
    We experienced some strange thing in our mongodb gridfs platform. The platform actually is a bi Xeon E5 (bi quad core) with 128GB of memory, running on freebsd 9 with a zfs pool dedicated for mongodb. [root@mongofile1 ~]# uname -sr FreeBSD 9.1-RELEASE our /boot/loader.conf vfs.zfs.arc_min="2048M" vfs.zfs.arc_max="7680M" vm.kmem_size_max="16G" vm.kmem_size="12G" vfs.zfs.prefetch_disable="1" kern.ipc.nmbclusters="32768" /etc/sysctl.conf net.inet.tcp.msl=15000 net.inet.tcp.keepidle=300000 kern.ipc.nmbclusters=32768 kern.ipc.maxsockbuf=2097152 kern.ipc.somaxconn=8192 kern.maxfiles=65536 kern.maxfilesperproc=32768 net.inet.tcp.delayed_ack=0 net.inet.tcp.sendspace=65535 net.inet.udp.recvspace=65535 net.inet.udp.maxdgram=57344 net.local.stream.recvspace=65535 net.local.stream.sendspace=65535 we follow the recommendation for the ulimit : [root@mongofile1 ~]# su - mongodb $ ulimit -a cpu time (seconds, -t) unlimited file size (512-blocks, -f) unlimited data seg size (kbytes, -d) 33554432 stack size (kbytes, -s) 524288 core file size (512-blocks, -c) unlimited max memory size (kbytes, -m) unlimited locked memory (kbytes, -l) unlimited max user processes (-u) 5547 open files (-n) 32768 virtual mem size (kbytes, -v) unlimited swap limit (kbytes, -w) unlimited sbsize (bytes, -b) unlimited pseudo-terminals (-p) unlimited This server have a twin (same config exactly) for ReplSet in other data center and we have a virtualized arbiter. Some time, almost 3 days, the process of mongodb exit. The problem begin with: Fri Nov 8 11:27:31.741 [conn774697] end connection 192.168.10.162:47963 (23 connections now open) Fri Nov 8 11:27:31.770 [initandlisten] can't create new thread, closing connection Fri Nov 8 11:27:31.771 [rsHealthPoll] replSet member mongofile2:27017 is now in state DOWN Fri Nov 8 11:27:31.774 [initandlisten] connection accepted from 192.168.10.162:47968 #774702 (20 connections now open) Fri Nov 8 11:27:31.774 [initandlisten] connection accepted from 192.168.10.161:28522 #774703 (21 connections now open) Fri Nov 8 11:27:31.774 [initandlisten] connection accepted from 192.168.10.164:15406 #774704 (22 connections now open) Fri Nov 8 11:27:31.774 [initandlisten] connection accepted from 192.168.10.163:25750 #774705 (23 connections now open) Fri Nov 8 11:27:31.810 [initandlisten] connection accepted from 192.168.10.182:20779 #774706 (24 connections now open) Fri Nov 8 11:27:31.855 [initandlisten] connection accepted from 192.168.10.161:28524 #774707 (25 connections now open) Fri Nov 8 11:27:31.869 [initandlisten] connection accepted from 192.168.10.182:20786 #774708 (26 connections now open) and after many "can create new thread" [root@mongofile1 /usr/mongodb]# tail -n 15000 mongod.log.old |grep "create new thread"|wc 5020 55220 421680 and finish by a magnificent Fri Nov 8 11:30:22.333 [rsMgr] replSet warning caught unexpected exception in electSelf() pure virtual method called Fri Nov 8 11:30:22.333 Got signal: 6 (Abort trap: 6). Fri Nov 8 11:30:22.337 Backtrace: 0x599efc 0x8035cb516 0x599efc <_ZN5mongo10abruptQuitEi+988> at /usr/local/bin/mongod 0x8035cb516 <_pthread_sigmask+918> at /lib/libthr.so.3 Extract of mongodb from top 78126 mongodb 77 20 0 1253G 1449M sbwait 0 0:20 0.00% mongod If I restart the process when it crash, the problem is fixed for almost 3 days. Has anyone seen this before, or know of a fix?

    Read the article

  • RHEL 5 list missing critical patches/packages

    - by Vinnie Biros
    Im trying to figure out if there is an easy way to identify the missing critical patches/packages on my RHEL5 boxes. This is for audit purposes and was trying to figure out if there was an RPM command or something of the sort that would accomplish this easily. I know with my Solaris 10 boxes, i can run the "smpatch analyze" command which would display this information for me. Anyone know of anything similar for RHEL5? Thanks.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >