2017-04-10 7 views
6

मैं एक पावरहेल वर्कफ़्लो ट्रिगर करने की कोशिश कर रहा हूं जो समानांतर में 10 धागे स्पिन करना चाहिए। मैं पी एस संस्करण का उपयोग कर रहा 4. कोड -वीएम पर कंकूरेंट पावरहेल उदाहरण की संख्या कैसे बढ़ाएं?

Workflow CreateVMs 
{ 
    $i = 0 
    #somecodehere... 
    foreach -parallel -throttlelimit 10($i in 0..30) 
    { 
     #somemorecodehere... 
     # INVOKING BATCH FILE USING POWERSHELL 
    } 
} 

मैं अपने इनलाइन स्क्रिप्ट के अंदर powershell का उपयोग कर बैच फ़ाइलों लागू कर रहा हूँ। क्या मैं कार्य प्रबंधक में मनाया, है केवल 5 धागे एक समय

enter image description here

में सक्रिय थे हो सकता है अगले धागा उठाया हो रही केवल पांच में से एक पूरा हो गया है। मैंने कभी 5 से अधिक ps उदाहरण नहीं देखा। हालांकि, जब मैं ps सत्र प्रति उपयोगकर्ता की अनुमति की जाँच की यह अब तक एक से अधिक 5.

enter image description here

कैसे मैं एक पी एस कार्यप्रवाह में समानांतर में पी एस के 10 धागे स्पिन कर सकते हैं। मुझे यहां क्या याद आ रही है?

+1

जब तक समानांतर गतिविधियों की संख्या थ्रॉटल सीमा से अधिक न हो, वर्कफ़्लो फाउंडेशन थ्रेड/गतिविधि पूल को अपने स्वयं के रूप में प्रबंधित करेगा, आपके लिए इसे "तेज़ी से जाने" के लिए मजबूर करने का कोई तरीका नहीं है –

+0

मेरे मामले में यह थ्रॉटल सीमा तक भी नहीं पहुंच रहा है। – Atf

+0

यह सुनिश्चित नहीं है कि यह आपके लिए काम करेगा, लेकिन क्या आपने स्टार्ट-जॉब cmdlet का उपयोग करने पर विचार किया है जो आप करने की कोशिश कर रहे हैं? https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/start-job –

उत्तर

1

निम्नलिखित नमूना स्क्रिप्ट को देखते हुए:

2017-11-28T13:27:34: Starting number 09 for 25 seconds 
2017-11-28T13:27:34: Starting number 10 for 36 seconds 
2017-11-28T13:27:34: Starting number 08 for 53 seconds 
2017-11-28T13:27:35: Starting number 06 for 17 seconds 
2017-11-28T13:27:35: Starting number 07 for 28 seconds 
2017-11-28T13:27:35: Starting number 05 for 33 seconds 
2017-11-28T13:27:35: Starting number 04 for 49 seconds 
2017-11-28T13:27:35: Starting number 02 for 18 seconds 
2017-11-28T13:27:35: Starting number 03 for 47 seconds 
2017-11-28T13:27:35: Starting number 01 for 45 seconds 
2017-11-28T13:27:52: Stopping number 06 after 17 seconds 
2017-11-28T13:27:55: Starting number 11 for 49 seconds 
2017-11-28T13:27:55: Stopping number 02 after 18 seconds 
2017-11-28T13:27:55: Starting number 12 for 55 seconds 
2017-11-28T13:28:00: Stopping number 09 after 25 seconds 
2017-11-28T13:28:00: Starting number 13 for 37 seconds 
2017-11-28T13:28:03: Stopping number 07 after 28 seconds 
2017-11-28T13:28:03: Starting number 14 for 46 seconds 
2017-11-28T13:28:08: Stopping number 05 after 33 seconds 
2017-11-28T13:28:08: Starting number 15 for 48 seconds 
2017-11-28T13:28:11: Stopping number 10 after 36 seconds 
2017-11-28T13:28:11: Starting number 16 for 57 seconds 
2017-11-28T13:28:21: Stopping number 01 after 45 seconds 
2017-11-28T13:28:21: Starting number 17 for 22 seconds 
2017-11-28T13:28:22: Stopping number 03 after 47 seconds 
2017-11-28T13:28:22: Starting number 18 for 39 seconds 
2017-11-28T13:28:24: Stopping number 04 after 49 seconds 
2017-11-28T13:28:24: Starting number 19 for 34 seconds 
2017-11-28T13:28:28: Stopping number 08 after 53 seconds 
2017-11-28T13:28:28: Starting number 20 for 58 seconds 
2017-11-28T13:28:37: Stopping number 13 after 37 seconds 
2017-11-28T13:28:43: Stopping number 17 after 22 seconds 
2017-11-28T13:28:44: Stopping number 11 after 49 seconds 
2017-11-28T13:28:49: Stopping number 14 after 46 seconds 
2017-11-28T13:28:50: Stopping number 12 after 55 seconds 
2017-11-28T13:28:56: Stopping number 15 after 48 seconds 
2017-11-28T13:28:58: Stopping number 19 after 34 seconds 
2017-11-28T13:29:01: Stopping number 18 after 39 seconds 
2017-11-28T13:29:08: Stopping number 16 after 57 seconds 
2017-11-28T13:29:26: Stopping number 20 after 58 seconds 

आप आउटपुट से देख सकते हैं, लूप के 10 उदाहरणों समवर्ती भी चल रहे हैं:

Workflow Test-Workflow 
{ 
    foreach -Parallel -ThrottleLimit 10 ($Number in 1..20) 
    { 
     $RandomSeconds = Get-Random -Minimum 10 -Maximum 60 

     InlineScript 
     { 
      $String = '{0:s}: Starting number {1:D2} for {2:D2} seconds' -f (Get-Date),$Using:Number,$Using:RandomSeconds 
      Write-Host -Object $String 
     } 

     Start-Sleep -Seconds $RandomSeconds 

     InlineScript 
     { 
      $String = '{0:s}: Stopping number {1:D2} after {2:D2} seconds' -f (Get-Date),$Using:Number,$Using:RandomSeconds 
      Write-Host -Object $String 
     } 
    } 
} 
Test-Workflow 

आपको निम्न जैसा उत्पादन मिल जाएगा हालांकि मेरे पास 10 powerhell.exe उदाहरण नहीं चल रहे हैं। आप InlineScript का उपयोग अपने उदाहरण में उपरोक्त रूप से देखने के लिए कर सकते हैं जब आपका वर्कफ़्लो प्रारंभ हो रहा है और/या आपके लूप का उदाहरण रोक रहा है।

+0

आप 2 इनलाइनस्क्रिप्ट ब्लॉक का उपयोग क्यों कर रहे हैं? – Atf

+0

@ एटीएफ मैं प्रत्येक पुनरावृत्ति के प्रारंभ और बंद समय को प्रदर्शित करने के लिए इनलाइन स्क्रिप्ट ब्लॉक का उपयोग कर रहा था। जैसा कि आप आउटपुट से देख सकते हैं, यह दिखाता है कि 10 समवर्ती पुनरावृत्तियों चल रहे हैं। –

+0

आपके उत्तर के लिए धन्यवाद। लेकिन आपके मामले में इनलाइन स्क्रिप्ट के अंदर के आदेश किसी भी प्रक्रिया को नहीं बना रहे हैं। यह एक साधारण लेखन-मेजबान चीज है। मैंने अपनी इनलाइन स्क्रिप्ट के अंदर पावरहेल का उपयोग करके विभिन्न बैच फ़ाइलों का आह्वान किया और व्यवहार समान है। मेरी समस्या अभी भी कार्य प्रबंधक में केवल 5 धागे शक्तियों को देखा जा सकता है जो वास्तविक है। – Atf

संबंधित मुद्दे