Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-PodeTask #1107

Closed
ericxin1982 opened this issue Jun 29, 2023 · 3 comments · Fixed by #1114
Closed

Invoke-PodeTask #1107

ericxin1982 opened this issue Jun 29, 2023 · 3 comments · Fixed by #1114
Assignees
Milestone

Comments

@ericxin1982
Copy link

Question

A clear and concise description of your question.

Register-PodeEvent -Type Start -Name 'ProjInit' -ScriptBlock {
$connection = GetConnectionString
Write-Host "$([DateTime]::Now)"
$dbpipe = New-SqlConnection $connection
##global state tree setup, then the whole app can reach the db connection by get-podestate
Set-PodeState -Name 'db' -Value @{ 't254' = $dbpipe } | Out-Null
Invoke-PodeTask -name 'xxxxxx' | out-null
}

Hi @Badgerati

I put invoke-podetask inside register-podeevent -type start, and it does not work, I am curious why.
invoke-podetask inside add-poderoute, and inside Add-PodeSchedule, it works fine.

I just try to make invoke-podetask can trigger when start.
It does not support?

Thanks
Eric Xin

@Badgerati
Copy link
Owner

Hi @ericxin1982,

This will be because the Start event is triggered before any of the Runspaces are actually created, so you can load anything additional if required.

To have this work, we'll probably need a new Event, something like Running perhaps 🤔 I can have a look.

@ericxin1982
Copy link
Author

Ok, I see. That is not rush, I am using this instead after start trigger event.

image

But if I can put task on start or running that would be much better.

Thanks
Eric Xin

@Badgerati Badgerati reopened this Jul 7, 2023
@Badgerati Badgerati added this to the 2.9.0 milestone Jul 7, 2023
Badgerati added a commit that referenced this issue Jul 8, 2023
@Badgerati Badgerati self-assigned this Jul 8, 2023
@Badgerati
Copy link
Owner

I've created a new Running event which will be triggered soon after the Start one. In the Running event all Runspaces will be open and available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants